@@ -72,8 +72,8 @@ var _ = g.Describe("[Feature:Prometheus][Feature:Builds] Prometheus", func() {
7272 activeTests := map [string ][]metricTest {
7373 activeBuildQuery : {
7474 metricTest {
75- labels : map [string ]string {"name" : "frontend-1" },
76- greaterThan : true ,
75+ labels : map [string ]string {"name" : "frontend-1" },
76+ greaterThanEqual : true ,
7777 },
7878 },
7979 }
@@ -88,14 +88,16 @@ var _ = g.Describe("[Feature:Prometheus][Feature:Builds] Prometheus", func() {
8888 terminalTests := map [string ][]metricTest {
8989 buildCountQuery : {
9090 metricTest {
91- labels : map [string ]string {"phase" : string (buildapi .BuildPhaseComplete )},
92- greaterThan : true ,
91+ labels : map [string ]string {"phase" : string (buildapi .BuildPhaseComplete )},
92+ greaterThanEqual : true ,
9393 },
9494 metricTest {
95- labels : map [string ]string {"phase" : string (buildapi .BuildPhaseCancelled )},
95+ labels : map [string ]string {"phase" : string (buildapi .BuildPhaseCancelled )},
96+ greaterThanEqual : true ,
9697 },
9798 metricTest {
98- labels : map [string ]string {"phase" : string (buildapi .BuildPhaseFailed )},
99+ labels : map [string ]string {"phase" : string (buildapi .BuildPhaseFailed )},
100+ greaterThanEqual : true ,
99101 },
100102 },
101103 }
@@ -120,10 +122,14 @@ type prometheusResponseData struct {
120122}
121123
122124type metricTest struct {
123- labels map [string ]string
124- greaterThan bool
125- value float64
126- success bool
125+ labels map [string ]string
126+ // we are not more precise (greater than only, or equal only) becauses the extended build tests
127+ // run in parallel on the CI system, and some of the metrics are cross namespace, so we cannot
128+ // reliably filter; we do precise count validation in the unit tests, where "entire cluster" activity
129+ // is more controlled :-)
130+ greaterThanEqual bool
131+ value float64
132+ success bool
127133}
128134
129135func runQueries (metricTests map [string ][]metricTest ) {
@@ -209,10 +215,10 @@ func labelsWeWant(sample *model.Sample, labels map[string]string) bool {
209215}
210216
211217func valueWeWant (sample * model.Sample , tc metricTest ) bool {
212- //NOTE - we could use SampleValue has an Equals func, but since SampleValue has no GreaterThan ,
218+ //NOTE - we could use SampleValue has an Equals func, but since SampleValue has no GreaterThanEqual ,
213219 // we have to go down the float64 compare anyway
214- if tc .greaterThan {
215- return float64 (sample .Value ) > tc .value
220+ if tc .greaterThanEqual {
221+ return float64 (sample .Value ) >= tc .value
216222 }
217- return float64 (sample .Value ) == tc .value
223+ return float64 (sample .Value ) < tc .value
218224}
0 commit comments