Skip to content

Commit

Permalink
Chore: add checks and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelThamm committed Sep 25, 2024
1 parent 548ac2f commit f5b0ce3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
23 changes: 14 additions & 9 deletions goss/goss_pebble_checks.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Charm Pebble health checks
command:
{{ if .Vars.enable_pebble_tests }}
{{ if .Vars.enable_pebble_tests }}
# $root is required to access the root context of the current template,
# which refers to the entire data structure being passed into the template.
# This provides access to .Vars and .Env in loops like the one below.
{{- $root := . -}}
{{range $app := .Vars.apps.k8s}}
pebble-{{$app.name}}:
exec: juju ssh -m {{ $root.Vars.model_name }} {{$app.name}}/0 /charm/bin/pebble health
exit-status: 0
stdout:
have-patterns:
- healthy
stderr: ""
pebble-{{$app.name}}:
exec: juju ssh -m {{ $root.Vars.model_name }} {{$app.name}}/0 /charm/bin/pebble health
exit-status: 0
stdout:
have-patterns:
- healthy
stderr: ""
{{end}}
{{end}}
k8s-charms:
exec: bash goss/scripts/test-k8s-probes.sh
exit-status: 0
stdout: ""
stderr: ""
{{end}}
2 changes: 1 addition & 1 deletion goss/scripts/compare-dashboard-uids.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Collect the UID from the charm dashboard and check if it is a subset of Grafana dashboard UIDs

Expand Down
2 changes: 1 addition & 1 deletion goss/scripts/test-internal-routing.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Obtain the alertmanager_url from Loki's loki-local-config.yaml and test routability from Loki's charm container

Expand Down
12 changes: 12 additions & 0 deletions goss/scripts/test-k8s-probes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

pod_ips=$(kubectl get pods -n cos-model -o jsonpath='{.items[*].status.podIP}' | tr ' ' '\n')

# Loop over each IP address
echo "$pod_ips" | while IFS= read -r ip; do

health=$(curl -sL http://$ip:38812/v1/health | jq -r '.result.healthy')
if [ "$health" != "true" ]; then
echo "Curl failed for $ip"
fi
done

0 comments on commit f5b0ce3

Please sign in to comment.