Skip to content

Commit 5e6abe6

Browse files
committed
fix test
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
1 parent f334cab commit 5e6abe6

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

pkg/cortex/cortex_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestCortex(t *testing.T) {
4646
// these values are set as defaults but since we aren't registering them, we
4747
// need to include the defaults here. These were hardcoded in a previous version
4848
// of weaveworks server.
49+
NameValidationScheme: model.LegacyValidation,
4950
Server: server.Config{
5051
GRPCListenNetwork: server.DefaultNetwork,
5152
HTTPListenNetwork: server.DefaultNetwork,
@@ -252,9 +253,10 @@ func TestGrpcAuthMiddleware(t *testing.T) {
252253
prepareGlobalMetricsRegistry(t)
253254

254255
cfg := Config{
255-
AuthEnabled: true, // We must enable this to enable Auth middleware for gRPC server.
256-
Server: getServerConfig(t),
257-
Target: []string{API}, // Something innocent that doesn't require much config.
256+
AuthEnabled: true, // We must enable this to enable Auth middleware for gRPC server.
257+
Server: getServerConfig(t),
258+
Target: []string{API}, // Something innocent that doesn't require much config.
259+
NameValidationScheme: model.LegacyValidation,
258260
}
259261

260262
msch := &mockGrpcServiceHandler{}

pkg/distributor/distributor_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,8 +3198,6 @@ func prepare(tb testing.TB, cfg prepConfig) ([]*Distributor, []*mockIngester, []
31983198
if cfg.nameValidationScheme == model.UTF8Validation {
31993199
distributorCfg.NameValidationScheme = cfg.nameValidationScheme
32003200
}
3201-
// set name validation scheme
3202-
model.NameValidationScheme = distributorCfg.NameValidationScheme //nolint:staticcheck
32033201

32043202
if cfg.shuffleShardEnabled {
32053203
distributorCfg.ShardingStrategy = util.ShardingStrategyShuffle

pkg/util/validation/limits_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,29 @@ func TestLimits_Validate(t *testing.T) {
125125
expected: errInvalidLabelValue,
126126
},
127127
"utf8: external-labels utf8 label name and value": {
128-
limits: Limits{RulerExternalLabels: labels.FromStrings("test.utf8.metric", "😄")},
129-
expected: nil,
128+
limits: Limits{RulerExternalLabels: labels.FromStrings("test.utf8.metric", "😄")},
129+
expected: nil,
130+
nameValidationScheme: model.UTF8Validation,
130131
},
131132
"utf8: external-labels invalid label name": {
132-
limits: Limits{RulerExternalLabels: labels.FromStrings("test.\xc5.metric", "😄")},
133-
expected: errInvalidLabelName,
133+
limits: Limits{RulerExternalLabels: labels.FromStrings("test.\xc5.metric", "😄")},
134+
expected: errInvalidLabelName,
135+
nameValidationScheme: model.UTF8Validation,
134136
},
135137
"utf8: external-labels invalid label value": {
136-
limits: Limits{RulerExternalLabels: labels.FromStrings("test.utf8.metric", "test.\xc5.value")},
137-
expected: errInvalidLabelValue,
138+
limits: Limits{RulerExternalLabels: labels.FromStrings("test.utf8.metric", "test.\xc5.value")},
139+
expected: errInvalidLabelValue,
140+
nameValidationScheme: model.UTF8Validation,
138141
},
139142
}
140143

141144
for testName, testData := range tests {
142-
143145
t.Run(testName, func(t *testing.T) {
144-
assert.ErrorIs(t, testData.limits.Validate(testData.nameValidationScheme, testData.shardByAllLabels, testData.activeSeriesMetricsEnabled), testData.expected)
146+
nameValidationScheme := model.LegacyValidation
147+
if testData.nameValidationScheme == model.UTF8Validation {
148+
nameValidationScheme = testData.nameValidationScheme
149+
}
150+
assert.ErrorIs(t, testData.limits.Validate(nameValidationScheme, testData.shardByAllLabels, testData.activeSeriesMetricsEnabled), testData.expected)
145151
})
146152
}
147153
}

0 commit comments

Comments
 (0)