forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helm: Integration testing (grafana#641)
* Helm chart integration testing Signed-off-by: Steven Sheehy <ssheehy@firescope.com> * Don't check helm version on every push Signed-off-by: Steven Sheehy <ssheehy@firescope.com> * Remove chart upgrade testing Signed-off-by: Steven Sheehy <ssheehy@firescope.com>
- Loading branch information
1 parent
fcd19e4
commit 8ed4a47
Showing
4 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
production/helm/loki-stack/templates/tests/loki-test-configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "loki-stack.fullname" . }}-test | ||
labels: | ||
app: {{ template "loki-stack.name" . }} | ||
chart: {{ template "loki-stack.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
data: | ||
test.sh: | | ||
#!/usr/bin/env bash | ||
LOKI_URI="http://${LOKI_SERVICE}:${LOKI_PORT}" | ||
function setup() { | ||
apk add -u curl jq | ||
until (curl -s ${LOKI_URI}/api/prom/label/app/values | jq -e '.values[] | select(. == "loki")'); do | ||
sleep 1 | ||
done | ||
} | ||
@test "Has labels" { | ||
curl -s ${LOKI_URI}/api/prom/label | \ | ||
jq -e '.values[] | select(. == "app")' | ||
} | ||
@test "Query log entry" { | ||
curl -sG ${LOKI_URI}/api/prom/query?limit=10 --data-urlencode 'query={app="loki"}' | \ | ||
jq -e '.streams[].entries | length >= 1' | ||
} | ||
@test "Push log entry" { | ||
local timestamp=$(date -Iseconds -u | sed 's/UTC/.000000000+00:00/') | ||
local data=$(jq -n --arg timestamp "${timestamp}" '{"streams": [{"labels": "{app=\"loki-test\"}", "entries": [{"ts": $timestamp, "line": "foobar"}]}]}') | ||
curl -s -X POST -H "Content-Type: application/json" ${LOKI_URI}/api/prom/push -d "${data}" | ||
curl -sG ${LOKI_URI}/api/prom/query?limit=1 --data-urlencode 'query={app="loki-test"}' | \ | ||
jq -e '.streams[].entries[].line == "foobar"' | ||
} | ||
30 changes: 30 additions & 0 deletions
30
production/helm/loki-stack/templates/tests/loki-test-pod.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
"helm.sh/hook": test-success | ||
labels: | ||
app: {{ template "loki-stack.name" . }} | ||
chart: {{ template "loki-stack.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
name: {{ template "loki-stack.fullname" . }}-test | ||
spec: | ||
containers: | ||
- name: test | ||
image: bats/bats:v1.1.0 | ||
args: | ||
- /var/lib/loki/test.sh | ||
env: | ||
- name: LOKI_SERVICE | ||
value: {{ template "loki.serviceName" . }} | ||
- name: LOKI_PORT | ||
value: "{{ .Values.loki.service.port }}" | ||
volumeMounts: | ||
- name: tests | ||
mountPath: /var/lib/loki | ||
restartPolicy: Never | ||
volumes: | ||
- name: tests | ||
configMap: | ||
name: {{ template "loki-stack.fullname" . }}-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters