(t *testing.T, appV2 bool)
| 1408 | } |
| 1409 | |
| 1410 | func testScrapeLoopFailLegacyUnderUTF8(t *testing.T, appV2 bool) { |
| 1411 | sl, _ := newTestScrapeLoop(t, withAppendable(teststorage.NewAppendable(), appV2), func(sl *scrapeLoop) { |
| 1412 | sl.validationScheme = model.LegacyValidation |
| 1413 | }) |
| 1414 | |
| 1415 | app := sl.appender() |
| 1416 | total, added, seriesAdded, err := app.append([]byte("{\"test.metric\"} 1\n"), "text/plain", time.Time{}) |
| 1417 | require.ErrorContains(t, err, "invalid metric name or label names") |
| 1418 | require.NoError(t, app.Rollback()) |
| 1419 | require.Equal(t, 1, total) |
| 1420 | require.Equal(t, 0, added) |
| 1421 | require.Equal(t, 0, seriesAdded) |
| 1422 | |
| 1423 | // When scrapeloop has validation set to UTF-8, the metric is allowed. |
| 1424 | sl, _ = newTestScrapeLoop(t, withAppendable(teststorage.NewAppendable(), appV2), func(sl *scrapeLoop) { |
| 1425 | sl.validationScheme = model.UTF8Validation |
| 1426 | }) |
| 1427 | |
| 1428 | app = sl.appender() |
| 1429 | total, added, seriesAdded, err = app.append([]byte("{\"test.metric\"} 1\n"), "text/plain", time.Time{}) |
| 1430 | require.NoError(t, err) |
| 1431 | require.Equal(t, 1, total) |
| 1432 | require.Equal(t, 1, added) |
| 1433 | require.Equal(t, 1, seriesAdded) |
| 1434 | } |
| 1435 | |
| 1436 | func readTextParseTestMetrics(t testing.TB) []byte { |
| 1437 | t.Helper() |
no test coverage detected
searching dependent graphs…