@@ -163,6 +163,40 @@ foo,BACKEND,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,5007,0,,1,8,1,,0,,2,0,,0,L4O
163
163
}
164
164
}
165
165
166
+ func TestOlderHaproxyVersions (t * testing.T ) {
167
+ const data = `foo,FRONTEND,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,5007,0,,1,8,1,,0,,2,
168
+ foo,foo-instance-0,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,5007,0,,1,8,1,,0,,2,
169
+ foo,BACKEND,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,5007,0,,1,8,1,,0,,2,
170
+ `
171
+ h := newHaproxy ([]byte (data ))
172
+ defer h .Close ()
173
+
174
+ e , _ := NewExporter (h .URL , serverMetrics , 5 * time .Second )
175
+ ch := make (chan prometheus.Metric )
176
+
177
+ go func () {
178
+ defer close (ch )
179
+ e .Collect (ch )
180
+ }()
181
+
182
+ if expect , got := 1. , readGauge ((<- ch ).(prometheus.Gauge )); expect != got {
183
+ // up
184
+ t .Errorf ("expected %f up, got %f" , expect , got )
185
+ }
186
+ if expect , got := 1. , readCounter ((<- ch ).(prometheus.Counter )); expect != got {
187
+ // totalScrapes
188
+ t .Errorf ("expected %f recorded scrape, got %f" , expect , got )
189
+ }
190
+ if expect , got := 0. , readCounter ((<- ch ).(prometheus.Counter )); expect != got {
191
+ // csvParseFailures
192
+ t .Errorf ("expected %f csv parse failures, got %f" , expect , got )
193
+ }
194
+
195
+ // Suck up the remaining metrics.
196
+ for range ch {
197
+ }
198
+ }
199
+
166
200
func TestConfigChangeDetection (t * testing.T ) {
167
201
h := newHaproxy ([]byte ("" ))
168
202
defer h .Close ()
0 commit comments