github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/_utils/check_metric_not_contains (about)

     1  #!/bin/bash
     2  # parameter 1: port
     3  # parameter 2: metric name
     4  # parameter 3: retry count, if check failed we will wait 1s before next retry, until retry time exceeds retry count
     5  
     6  set -eu
     7  
     8  port=$1
     9  metric_name=$2
    10  retry_count=$3
    11  
    12  shift 3
    13  
    14  counter=0
    15  while [ $counter -lt $retry_count ]; do
    16  	metric=$(curl -s http://127.0.0.1:$port/metrics | grep $metric_name | wc -l)
    17  	if [ $metric -eq 0 ]; then
    18  		exit 0
    19  	fi
    20  	((counter += 1))
    21  	echo "wait for valid metric for $counter-th time"
    22  	sleep 1
    23  done
    24  
    25  echo "metric $metric_name has invalid count $metric"
    26  exit 1