|
2 | 2 | apiVersion: kuttl.dev/v1beta1
|
3 | 3 | kind: TestStep
|
4 | 4 | commands:
|
5 |
| - # Ensure that the metrics endpoint is available from inside the exporter container |
6 | 5 | - script: |
|
7 |
| - name=$(kubectl -n ${NAMESPACE} get pods --no-headers -o custom-columns="name:{metadata.name}" \ |
8 |
| - --selector='postgres-operator.crunchydata.com/cluster=exporter,postgres-operator.crunchydata.com/instance-set=instance1') |
9 |
| - kubectl -n ${NAMESPACE} exec $name -it -c exporter -- curl http://localhost:9187/metrics |
10 |
| - # Ensure that the ccp_monitoring user exists in the database |
11 |
| - - script: | |
12 |
| - name=$(kubectl -n ${NAMESPACE} get pods --no-headers -o custom-columns="name:{metadata.name}" \ |
13 |
| - --selector='postgres-operator.crunchydata.com/cluster=exporter,postgres-operator.crunchydata.com/instance-set=instance1') |
14 |
| - kubectl -n ${NAMESPACE} exec $name -it -c database -- \ |
15 |
| - psql -c "DO \$\$ |
| 6 | + set -e |
| 7 | + PRIMARY=$( |
| 8 | + kubectl get pod --namespace "${NAMESPACE}" \ |
| 9 | + --output name --selector ' |
| 10 | + postgres-operator.crunchydata.com/cluster=exporter, |
| 11 | + postgres-operator.crunchydata.com/role=master' |
| 12 | + ) |
| 13 | +
|
| 14 | + # Ensure that the metrics endpoint is available from inside the exporter container |
| 15 | + kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" -c exporter -- curl http://localhost:9187/metrics |
| 16 | +
|
| 17 | + # Ensure that the monitoring user exists and is configured. |
| 18 | + kubectl exec --stdin --namespace "${NAMESPACE}" "${PRIMARY}" \ |
| 19 | + -- psql -qb --set ON_ERROR_STOP=1 --file=- <<'SQL' |
| 20 | + DO $$ |
16 | 21 | DECLARE
|
17 |
| - result boolean; |
| 22 | + result record; |
18 | 23 | BEGIN
|
19 |
| - SELECT 1 from pg_roles where rolname='ccp_monitoring' INTO result; |
20 |
| - ASSERT result = 't', 'ccp_monitor not found'; |
21 |
| - END \$\$;" |
| 24 | + SELECT * INTO result FROM pg_catalog.pg_roles WHERE rolname = 'ccp_monitoring'; |
| 25 | + ASSERT FOUND, 'user not found'; |
| 26 | + ASSERT result.rolconfig @> '{jit=off}', format('got config: %L', result.rolconfig); |
| 27 | + END $$ |
| 28 | + SQL |
0 commit comments