(t *testing.T, appV2 bool)
| 4895 | } |
| 4896 | |
| 4897 | func testScrapeLoopDiscardDuplicateLabels(t *testing.T, appV2 bool) { |
| 4898 | s := teststorage.New(t) |
| 4899 | |
| 4900 | appTest := teststorage.NewAppendable().Then(s) |
| 4901 | sl, _ := newTestScrapeLoop(t, withAppendable(appTest, appV2)) |
| 4902 | |
| 4903 | // We add a good and a bad metric to check that both are discarded. |
| 4904 | app := sl.appender() |
| 4905 | _, _, _, err := app.append([]byte("test_metric{le=\"500\"} 1\ntest_metric{le=\"600\",le=\"700\"} 1\n"), "text/plain", time.Time{}) |
| 4906 | require.Error(t, err) |
| 4907 | require.NoError(t, app.Rollback()) |
| 4908 | // We need to cycle staleness cache maps after a manual rollback. Otherwise, they will have old entries in them, |
| 4909 | // which would cause ErrDuplicateSampleForTimestamp errors on the next append. |
| 4910 | sl.cache.iterDone(true) |
| 4911 | |
| 4912 | q, err := s.Querier(time.Time{}.UnixNano(), 0) |
| 4913 | require.NoError(t, err) |
| 4914 | series := q.Select(sl.ctx, false, nil, labels.MustNewMatcher(labels.MatchRegexp, "__name__", ".*")) |
| 4915 | require.False(t, series.Next(), "series found in tsdb") |
| 4916 | require.NoError(t, series.Err()) |
| 4917 | |
| 4918 | // We add a good metric to check that it is recorded. |
| 4919 | app = sl.appender() |
| 4920 | _, _, _, err = app.append([]byte("test_metric{le=\"500\"} 1\n"), "text/plain", time.Time{}) |
| 4921 | require.NoError(t, err) |
| 4922 | require.NoError(t, app.Commit()) |
| 4923 | |
| 4924 | q, err = s.Querier(time.Time{}.UnixNano(), 0) |
| 4925 | require.NoError(t, err) |
| 4926 | series = q.Select(sl.ctx, false, nil, labels.MustNewMatcher(labels.MatchEqual, "le", "500")) |
| 4927 | require.True(t, series.Next(), "series not found in tsdb") |
| 4928 | require.NoError(t, series.Err()) |
| 4929 | require.False(t, series.Next(), "more than one series found in tsdb") |
| 4930 | } |
| 4931 | |
| 4932 | func TestScrapeLoopDiscardUnnamedMetrics(t *testing.T) { |
| 4933 | foreachAppendable(t, func(t *testing.T, appV2 bool) { |
no test coverage detected
searching dependent graphs…