@@ -17,6 +17,7 @@ package target
17
17
import (
18
18
"context"
19
19
"errors"
20
+ "hash"
20
21
"sort"
21
22
"testing"
22
23
"time"
@@ -252,6 +253,33 @@ func TestDiscovery_ScrapeConfigHashing(t *testing.T) {
252
253
},
253
254
},
254
255
},
256
+ {
257
+ description : "different regex" ,
258
+ cfg : & promconfig.Config {
259
+ ScrapeConfigs : []* promconfig.ScrapeConfig {
260
+ {
261
+ JobName : "serviceMonitor/testapp/testapp/1" ,
262
+ HonorTimestamps : false ,
263
+ ScrapeTimeout : model .Duration (30 * time .Second ),
264
+ MetricsPath : "/metrics" ,
265
+ Scheme : "http" ,
266
+ HTTPClientConfig : commonconfig.HTTPClientConfig {
267
+ FollowRedirects : true ,
268
+ },
269
+ RelabelConfigs : []* relabel.Config {
270
+ {
271
+ SourceLabels : model.LabelNames {model .LabelName ("job" )},
272
+ Separator : ";" ,
273
+ Regex : relabel .MustNewRegexp ("(.+)" ),
274
+ TargetLabel : "__tmp_prometheus_job_name" ,
275
+ Replacement : "$$1" ,
276
+ Action : relabel .Replace ,
277
+ },
278
+ },
279
+ },
280
+ },
281
+ },
282
+ },
255
283
{
256
284
description : "mock error on update - no hash update" ,
257
285
cfg : & promconfig.Config {
@@ -263,39 +291,9 @@ func TestDiscovery_ScrapeConfigHashing(t *testing.T) {
263
291
},
264
292
expectErr : true ,
265
293
},
266
- // {
267
- // TODO: fix handler logic so this test passes.
268
- // This test currently fails due to the regexp struct not having any
269
- // exported fields for the hashing algorithm to hash on, causing the
270
- // hashes to be the same even though the data is different.
271
- // description: "different regex",
272
- // cfg: &promconfig.Config{
273
- // ScrapeConfigs: []*promconfig.ScrapeConfig{
274
- // {
275
- // JobName: "serviceMonitor/testapp/testapp/1",
276
- // HonorTimestamps: false,
277
- // ScrapeTimeout: model.Duration(30 * time.Second),
278
- // MetricsPath: "/metrics",
279
- // HTTPClientConfig: commonconfig.HTTPClientConfig{
280
- // FollowRedirects: true,
281
- // },
282
- // RelabelConfigs: []*relabel.Config{
283
- // {
284
- // SourceLabels: model.LabelNames{model.LabelName("job")},
285
- // Separator: ";",
286
- // Regex: relabel.MustNewRegexp("something else"),
287
- // TargetLabel: "__tmp_prometheus_job_name",
288
- // Replacement: "$$1",
289
- // Action: relabel.Replace,
290
- // },
291
- // },
292
- // },
293
- // },
294
- // },
295
- // },
296
294
}
297
295
var (
298
- lastValidHash uint64
296
+ lastValidHash hash. Hash
299
297
expectedConfig map [string ]* promconfig.ScrapeConfig
300
298
lastValidConfig map [string ]* promconfig.ScrapeConfig
301
299
)
0 commit comments