mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-30 07:59:40 -08:00
Fix broken test which relied on DNS resolution #1962
Switched to testing by way of the static_configs rather than dns_sd_config parameter. Verified that the revised test both passes without network access, and also still catches the bug it's supposed to cover.
This commit is contained in:
parent
e5a5dc172d
commit
0cb6b9962e
|
@ -42,9 +42,9 @@ func TestTargetSetRecreatesTargetGroupsEveryRun(t *testing.T) {
|
||||||
|
|
||||||
sOne := `
|
sOne := `
|
||||||
job_name: "foo"
|
job_name: "foo"
|
||||||
dns_sd_configs:
|
static_configs:
|
||||||
- names:
|
- targets: ["foo:9090"]
|
||||||
- "srv.name.one.example.org"
|
- targets: ["bar:9090"]
|
||||||
`
|
`
|
||||||
if err := yaml.Unmarshal([]byte(sOne), scrapeConfig); err != nil {
|
if err := yaml.Unmarshal([]byte(sOne), scrapeConfig); err != nil {
|
||||||
t.Fatalf("Unable to load YAML config sOne: %s", err)
|
t.Fatalf("Unable to load YAML config sOne: %s", err)
|
||||||
|
@ -57,13 +57,13 @@ dns_sd_configs:
|
||||||
|
|
||||||
ts.runProviders(context.Background(), providersFromConfig(scrapeConfig))
|
ts.runProviders(context.Background(), providersFromConfig(scrapeConfig))
|
||||||
|
|
||||||
verifyPresence(ts.tgroups, "dns/0/srv.name.one.example.org", true)
|
verifyPresence(ts.tgroups, "static/0/0", true)
|
||||||
|
verifyPresence(ts.tgroups, "static/0/1", true)
|
||||||
|
|
||||||
sTwo := `
|
sTwo := `
|
||||||
job_name: "foo"
|
job_name: "foo"
|
||||||
dns_sd_configs:
|
static_configs:
|
||||||
- names:
|
- targets: ["foo:9090"]
|
||||||
- "srv.name.two.example.org"
|
|
||||||
`
|
`
|
||||||
if err := yaml.Unmarshal([]byte(sTwo), scrapeConfig); err != nil {
|
if err := yaml.Unmarshal([]byte(sTwo), scrapeConfig); err != nil {
|
||||||
t.Fatalf("Unable to load YAML config sTwo: %s", err)
|
t.Fatalf("Unable to load YAML config sTwo: %s", err)
|
||||||
|
@ -71,8 +71,8 @@ dns_sd_configs:
|
||||||
|
|
||||||
ts.runProviders(context.Background(), providersFromConfig(scrapeConfig))
|
ts.runProviders(context.Background(), providersFromConfig(scrapeConfig))
|
||||||
|
|
||||||
verifyPresence(ts.tgroups, "dns/0/srv.name.one.example.org", false)
|
verifyPresence(ts.tgroups, "static/0/0", true)
|
||||||
verifyPresence(ts.tgroups, "dns/0/srv.name.two.example.org", true)
|
verifyPresence(ts.tgroups, "static/0/1", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustNewRegexp(s string) config.Regexp {
|
func mustNewRegexp(s string) config.Regexp {
|
||||||
|
|
Loading…
Reference in a new issue