From 0d44248fb86eb991bc6c39f4270bd5ecb99afe2d Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Fri, 12 Feb 2016 15:43:48 +0100 Subject: [PATCH] Cleanup cluttered test data --- retrieval/targetmanager_test.go | 144 +++++++++++++++++++++++++------- 1 file changed, 116 insertions(+), 28 deletions(-) diff --git a/retrieval/targetmanager_test.go b/retrieval/targetmanager_test.go index b192a10c0..2eb5d9d75 100644 --- a/retrieval/targetmanager_test.go +++ b/retrieval/targetmanager_test.go @@ -313,44 +313,109 @@ func TestTargetManagerConfigUpdate(t *testing.T) { scrapeConfigs: []*config.ScrapeConfig{testJob1}, expected: map[string][]model.LabelSet{ "test_job1:static:0:0": { - {model.JobLabel: "test_job1", model.InstanceLabel: "example.org:80", "testParam": "paramValue", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.org:80", model.ParamLabelPrefix + "testParam": "paramValue"}, - {model.JobLabel: "test_job1", model.InstanceLabel: "example.com:80", "testParam": "paramValue", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.com:80", model.ParamLabelPrefix + "testParam": "paramValue"}, + { + model.JobLabel: "test_job1", + model.InstanceLabel: "example.org:80", + "testParam": "paramValue", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.org:80", + model.ParamLabelPrefix + "testParam": "paramValue", + }, + { + model.JobLabel: "test_job1", + model.InstanceLabel: "example.com:80", + "testParam": "paramValue", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.com:80", + model.ParamLabelPrefix + "testParam": "paramValue"}, }, }, }, { scrapeConfigs: []*config.ScrapeConfig{testJob1}, expected: map[string][]model.LabelSet{ "test_job1:static:0:0": { - {model.JobLabel: "test_job1", model.InstanceLabel: "example.org:80", "testParam": "paramValue", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.org:80", model.ParamLabelPrefix + "testParam": "paramValue"}, - {model.JobLabel: "test_job1", model.InstanceLabel: "example.com:80", "testParam": "paramValue", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.com:80", model.ParamLabelPrefix + "testParam": "paramValue"}, + { + model.JobLabel: "test_job1", + model.InstanceLabel: "example.org:80", + "testParam": "paramValue", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.org:80", + model.ParamLabelPrefix + "testParam": "paramValue", + }, + { + model.JobLabel: "test_job1", + model.InstanceLabel: "example.com:80", + "testParam": "paramValue", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.com:80", + model.ParamLabelPrefix + "testParam": "paramValue", + }, }, }, }, { scrapeConfigs: []*config.ScrapeConfig{testJob1, testJob2}, expected: map[string][]model.LabelSet{ "test_job1:static:0:0": { - {model.JobLabel: "test_job1", model.InstanceLabel: "example.org:80", "testParam": "paramValue", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.org:80", model.ParamLabelPrefix + "testParam": "paramValue"}, - {model.JobLabel: "test_job1", model.InstanceLabel: "example.com:80", "testParam": "paramValue", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.com:80", model.ParamLabelPrefix + "testParam": "paramValue"}, + { + model.JobLabel: "test_job1", + model.InstanceLabel: "example.org:80", + "testParam": "paramValue", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.org:80", + model.ParamLabelPrefix + "testParam": "paramValue", + }, + { + model.JobLabel: "test_job1", + model.InstanceLabel: "example.com:80", + "testParam": "paramValue", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.com:80", + model.ParamLabelPrefix + "testParam": "paramValue", + }, }, "test_job2:static:0:0": { - {model.JobLabel: "test_job2", model.InstanceLabel: "example.org:8080", "foo": "bar", "new": "ox-ba", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.org:8080"}, - {model.JobLabel: "test_job2", model.InstanceLabel: "example.com:8081", "foo": "bar", "new": "ox-ba", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.com:8081"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "example.org:8080", + "foo": "bar", + "new": "ox-ba", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.org:8080", + }, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "example.com:8081", + "foo": "bar", + "new": "ox-ba", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.com:8081", + }, }, "test_job2:static:0:1": { - {model.JobLabel: "test_job2", model.InstanceLabel: "foo.com:1234", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "foo.com:1234"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "foo.com:1234", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "foo.com:1234", + }, }, "test_job2:static:0:2": { - {model.JobLabel: "test_job2", model.InstanceLabel: "fixed", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "foo.com:1235"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "fixed", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "foo.com:1235", + }, }, }, }, { @@ -360,18 +425,41 @@ func TestTargetManagerConfigUpdate(t *testing.T) { scrapeConfigs: []*config.ScrapeConfig{testJob2}, expected: map[string][]model.LabelSet{ "test_job2:static:0:0": { - {model.JobLabel: "test_job2", model.InstanceLabel: "example.org:8080", "foo": "bar", "new": "ox-ba", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.org:8080"}, - {model.JobLabel: "test_job2", model.InstanceLabel: "example.com:8081", "foo": "bar", "new": "ox-ba", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "example.com:8081"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "example.org:8080", + "foo": "bar", + "new": "ox-ba", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.org:8080"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "example.com:8081", + "foo": "bar", + "new": "ox-ba", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "example.com:8081", + }, }, "test_job2:static:0:1": { - {model.JobLabel: "test_job2", model.InstanceLabel: "foo.com:1234", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "foo.com:1234"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "foo.com:1234", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "foo.com:1234", + }, }, "test_job2:static:0:2": { - {model.JobLabel: "test_job2", model.InstanceLabel: "fixed", - model.SchemeLabel: "", model.MetricsPathLabel: "", model.AddressLabel: "foo.com:1235"}, + { + model.JobLabel: "test_job2", + model.InstanceLabel: "fixed", + model.SchemeLabel: "", + model.MetricsPathLabel: "", + model.AddressLabel: "foo.com:1235", + }, }, }, }, {