From 4927e1353786c89e847e39c41a05a6f8ee464465 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 29 Jul 2022 13:20:44 +0100 Subject: [PATCH] scrape tests: undo EmptyLabels change Needs other code changes otherwise tests fail Signed-off-by: Bryan Boreham --- scrape/manager_test.go | 28 ++++++++++++++-------------- scrape/scrape_test.go | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scrape/manager_test.go b/scrape/manager_test.go index dd550511e..90aa1db28 100644 --- a/scrape/manager_test.go +++ b/scrape/manager_test.go @@ -149,8 +149,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "no address", }, // Address label missing, but added in relabelling. @@ -242,8 +242,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "invalid label value for \"custom\": \"\\xbd\"", }, // Invalid duration in interval label. @@ -259,8 +259,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "error parsing scrape interval: not a valid duration string: \"2notseconds\"", }, // Invalid duration in timeout label. @@ -276,8 +276,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "error parsing scrape timeout: not a valid duration string: \"2notseconds\"", }, // 0 interval in timeout label. @@ -293,8 +293,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "scrape interval cannot be 0", }, // 0 duration in timeout label. @@ -310,8 +310,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "scrape timeout cannot be 0", }, // Timeout less than interval. @@ -328,8 +328,8 @@ func TestPopulateLabels(t *testing.T) { ScrapeInterval: model.Duration(time.Second), ScrapeTimeout: model.Duration(time.Second), }, - res: labels.EmptyLabels(), - resOrig: labels.EmptyLabels(), + res: nil, + resOrig: nil, err: "scrape timeout cannot be greater than scrape interval (\"2s\" > \"1s\")", }, // Don't attach default port. diff --git a/scrape/scrape_test.go b/scrape/scrape_test.go index 3ce31878a..5493bd4dc 100644 --- a/scrape/scrape_test.go +++ b/scrape/scrape_test.go @@ -1577,7 +1577,7 @@ func TestScrapeLoopAppendSampleLimit(t *testing.T) { nil, nil, nil, func(l labels.Labels) labels.Labels { if l.Has("deleteme") { - return labels.EmptyLabels() + return nil } return l },