@@ -29,6 +29,23 @@ function assert_match()
29
29
exit 1; }
30
30
}
31
31
32
+ function contains()
33
+ {
34
+ local output=" $( cat -) "
35
+ local ret= acc=0
36
+ for pattern in " $@ " ; do
37
+ ret=" $( echo " $output " | grep -q -e " $pattern " ; echo " $? " ) "
38
+ if [ " $ret " -ne " 0" ]; then
39
+ [ " $(( $acc )) " -eq " 0" ] && {
40
+ echo " contains FAILED"
41
+ echo " output: '${output} '" ; }
42
+ echo " pattern is missing: '${pattern} '"
43
+ fi >&2
44
+ acc+=" +${ret} "
45
+ done
46
+ test " $(( $acc )) " " -eq" " 0"
47
+ }
48
+
32
49
function get_nodes()
33
50
{
34
51
curl -s -X GET " http://localhost:4000/nodes" -H " accept: application/json" \
@@ -42,13 +59,6 @@ function number_of_nodes()
42
59
| jq ' .nodes | length'
43
60
}
44
61
45
- function get_graphite_prefix()
46
- {
47
- local node=" $1 "
48
- curl -s -X GET " http://localhost:4000/status/$node " -H " accept: application/json" \
49
- | jq ' .env.AMOC_GRAPHITE_PREFIX | ltrimstr("\"") | rtrimstr("\"")' | sed ' s/"//g'
50
- }
51
-
52
62
function retry()
53
63
{
54
64
local n=" $1 " m=" 0"
@@ -62,27 +72,18 @@ function retry()
62
72
echo -e " \nsuccess after '$m ' retries" ;
63
73
}
64
74
65
- function are_metrics_reported ()
75
+ function metrics_reported ()
66
76
{
67
- local graphite_prefix=" $1 "
68
- local length=" $( curl -s " http://localhost:8080/metrics/find?query=${graphite_prefix} .*" | jq " length" ) "
69
- [ " $length " -gt " 0" ]
77
+ curl -s ' http://localhost:9090/api/v1/targets' | contains " $@ "
70
78
}
71
79
72
- function wait_for_reported_metrics()
73
- {
74
- local graphite_prefix=" $1 "
75
- retry 60 are_metrics_reported " $graphite_prefix "
80
+ function wait_for_metrics() {
81
+ retry 60 metrics_reported " $@ "
76
82
}
77
83
78
84
assert_equal " number of nodes" 3 " $( number_of_nodes) "
79
85
80
86
for node in $( get_nodes) ; do
81
87
assert_match " node name" " amoc_arsenal_xmpp@.*" " $node "
82
- if [ " $node " != " amoc_arsenal_xmpp@amoc-master" ]; then
83
- graphite_prefix=" $( get_graphite_prefix $node ) "
84
- wait_for_reported_metrics " $graphite_prefix "
85
- else
86
- wait_for_reported_metrics " amoc-master"
87
- fi
88
+ wait_for_metrics " amoc-master"
88
89
done
0 commit comments