Skip to content

Commit 669ca08

Browse files
authored
Merge pull request #666 from gabemontero/metrics-test
add test for exporter metrics
2 parents fae4d5a + d5d17de commit 669ca08

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
kind: PipelineRun
3+
apiVersion: tekton.dev/v1beta1
4+
metadata:
5+
generateName: metrics-curl-test-
6+
spec:
7+
serviceAccountName: appstudio-pipeline
8+
pipelineSpec:
9+
tasks:
10+
- name: metrics-curl
11+
taskSpec:
12+
steps:
13+
- image: registry.access.redhat.com/ubi8/ubi-minimal:8.7
14+
name: metrics-curl
15+
securityContext:
16+
runAsNonRoot: true
17+
script: |
18+
stats="$(curl http://pipeline-metrics-exporter-service.openshift-pipelines.svc.cluster.local:9117/metrics 2> /dev/null | grep pipelinerun_duration)"
19+
if [ -z "$stats" ]; then
20+
echo "FAILED: did not get pipelinerun_duration stats"
21+
echo $stats
22+
exit 1
23+
fi
24+
echo "SUCCESS: got pipelinerun_duration stats:"
25+
echo $stats

operator/test/test.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Optional arguments:
1919
Default value: \$KUBECONFIG
2020
-t, --test TEST
2121
Name of the test to be executed. Can be repeated to run multiple tests.
22-
Must be one of: chains, pipelines, results, security.
22+
Must be one of: chains, pipelines, results, security, metrics.
2323
Default: Run all tests.
2424
-d, --debug
2525
Activate tracing/debug mode.
@@ -62,7 +62,7 @@ parse_args() {
6262
done
6363
DEBUG="${DEBUG:-}"
6464
if [ "${#TEST_LIST[@]}" = "0" ]; then
65-
TEST_LIST=("chains" "pipelines" "results" "security")
65+
TEST_LIST=("chains" "pipelines" "results" "security" "metrics")
6666
fi
6767
}
6868

@@ -134,6 +134,13 @@ check_host_network() {
134134
done
135135
}
136136

137+
test_metrics() {
138+
prName="$(kubectl create -n "$NAMESPACE" -f "$SCRIPT_DIR/manifests/test/metrics/curl-metrics-service-pipeline.yaml" | awk '{print $1}')"
139+
echo "Checking $prName for metric output"
140+
wait_for_pipeline "$prName" "$NAMESPACE"
141+
echo "OK"
142+
}
143+
137144
test_chains() {
138145
kubectl apply -k "$SCRIPT_DIR/manifests/test/tekton-chains" -n "$NAMESPACE" >/dev/null
139146

@@ -331,7 +338,7 @@ main() {
331338
setup_test
332339
for case in "${TEST_LIST[@]}"; do
333340
case $case in
334-
chains | pipelines | results | security)
341+
chains | pipelines | results | security | metrics)
335342
echo "[$case]"
336343
test_"$case"
337344
echo

0 commit comments

Comments
 (0)