@ -15,7 +15,6 @@ package config
import (
"crypto/tls"
"encoding/json"
"fmt"
"net/url"
"os"
@ -62,11 +61,6 @@ import (
"github.com/prometheus/prometheus/util/testutil"
)
func init ( ) {
// This can be removed when the default validation scheme in common is updated.
model . NameValidationScheme = model . UTF8Validation
}
func mustParseURL ( u string ) * config . URL {
parsed , err := url . Parse ( u )
if err != nil {
@ -1716,11 +1710,7 @@ var expectedErrors = []struct {
} ,
{
filename : "labelname.bad.yml" ,
errMsg : ` "not$allowed" is not a valid label name ` ,
} ,
{
filename : "labelname2.bad.yml" ,
errMsg : ` "not:allowed" is not a valid label name ` ,
errMsg : ` "\xff" is not a valid label name ` ,
} ,
{
filename : "labelvalue.bad.yml" ,
@ -1792,16 +1782,12 @@ var expectedErrors = []struct {
} ,
{
filename : "labelmap.bad.yml" ,
errMsg : "\"l-$1\" is invalid 'replacement' for labelmap action " ,
errMsg : "!!binary value contains invalid base64 data " ,
} ,
{
filename : "lowercase.bad.yml" ,
errMsg : "relabel configuration for lowercase action requires 'target_label' value" ,
} ,
{
filename : "lowercase2.bad.yml" ,
errMsg : "\"42lab\" is invalid 'target_label' for lowercase action" ,
} ,
{
filename : "lowercase3.bad.yml" ,
errMsg : "'replacement' can not be set for lowercase action" ,
@ -1810,10 +1796,6 @@ var expectedErrors = []struct {
filename : "uppercase.bad.yml" ,
errMsg : "relabel configuration for uppercase action requires 'target_label' value" ,
} ,
{
filename : "uppercase2.bad.yml" ,
errMsg : "\"42lab\" is invalid 'target_label' for uppercase action" ,
} ,
{
filename : "uppercase3.bad.yml" ,
errMsg : "'replacement' can not be set for uppercase action" ,
@ -2181,10 +2163,6 @@ var expectedErrors = []struct {
}
func TestBadConfigs ( t * testing . T ) {
model . NameValidationScheme = model . LegacyValidation
defer func ( ) {
model . NameValidationScheme = model . UTF8Validation
} ( )
for _ , ee := range expectedErrors {
_ , err := LoadFile ( "testdata/" + ee . filename , false , promslog . NewNopLogger ( ) )
require . ErrorContains ( t , err , ee . errMsg ,
@ -2192,23 +2170,7 @@ func TestBadConfigs(t *testing.T) {
}
}
func TestBadStaticConfigsJSON ( t * testing . T ) {
model . NameValidationScheme = model . LegacyValidation
defer func ( ) {
model . NameValidationScheme = model . UTF8Validation
} ( )
content , err := os . ReadFile ( "testdata/static_config.bad.json" )
require . NoError ( t , err )
var tg targetgroup . Group
err = json . Unmarshal ( content , & tg )
require . Error ( t , err )
}
func TestBadStaticConfigsYML ( t * testing . T ) {
model . NameValidationScheme = model . LegacyValidation
defer func ( ) {
model . NameValidationScheme = model . UTF8Validation
} ( )
content , err := os . ReadFile ( "testdata/static_config.bad.yml" )
require . NoError ( t , err )
var tg targetgroup . Group
@ -2453,11 +2415,6 @@ func TestScrapeConfigDisableCompression(t *testing.T) {
}
func TestScrapeConfigNameValidationSettings ( t * testing . T ) {
model . NameValidationScheme = model . UTF8Validation
defer func ( ) {
model . NameValidationScheme = model . LegacyValidation
} ( )
tests := [ ] struct {
name string
inputFile string