File: 0012-Default-to-legacy-label-name-validation-in-tests.patch

package info (click to toggle)
prometheus-alertmanager 0.28.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,748 kB
  • sloc: makefile: 216; sh: 211; javascript: 86
file content (64 lines) | stat: -rw-r--r-- 1,797 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From: Daniel Swarbrick <dswarbrick@debian.org>
Date: Thu, 20 Feb 2025 01:51:32 +0100
Subject: Default to legacy label name validation in tests

Forwarded: not-needed
Last-Update: 2025-02-20

Restore pre-v0.62.0 prometheus/common default label name validation.
This patch can (and should) be dropped once Alertmanager is updated to
natively support prometheus/common v0.62.0+.
---
 config/config_test.go        | 5 +++++
 matcher/compat/parse_test.go | 5 +++++
 silence/silence_test.go      | 5 +++++
 3 files changed, 15 insertions(+)

diff --git a/config/config_test.go b/config/config_test.go
index 728d767..082d432 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -33,6 +33,11 @@ import (
 	"github.com/prometheus/alertmanager/matcher/compat"
 )
 
+func TestMain(m *testing.M) {
+	model.NameValidationScheme = model.LegacyValidation
+	m.Run()
+}
+
 func TestLoadEmptyString(t *testing.T) {
 	var in string
 	_, err := Load(in)
diff --git a/matcher/compat/parse_test.go b/matcher/compat/parse_test.go
index 803ee78..4d8ecbb 100644
--- a/matcher/compat/parse_test.go
+++ b/matcher/compat/parse_test.go
@@ -23,6 +23,11 @@ import (
 	"github.com/prometheus/alertmanager/pkg/labels"
 )
 
+func TestMain(m *testing.M) {
+	model.NameValidationScheme = model.LegacyValidation
+	m.Run()
+}
+
 func TestFallbackMatcherParser(t *testing.T) {
 	tests := []struct {
 		name     string
diff --git a/silence/silence_test.go b/silence/silence_test.go
index a65b1f6..e007aff 100644
--- a/silence/silence_test.go
+++ b/silence/silence_test.go
@@ -39,6 +39,11 @@ import (
 	"github.com/prometheus/alertmanager/types"
 )
 
+func TestMain(m *testing.M) {
+	model.NameValidationScheme = model.LegacyValidation
+	m.Run()
+}
+
 func checkErr(t *testing.T, expected string, got error) {
 	t.Helper()