test and scrape

Signed-off-by: Vanshikav123 <vanshikav928@gmail.com>
This commit is contained in:
Vanshikav123 2024-08-24 14:20:04 +05:30
parent 450578a8da
commit b13041020d
6 changed files with 9 additions and 2 deletions

View file

@ -1189,6 +1189,7 @@ func countStaleNaN(t *testing.T, st storage.Storage) int {
}
return c
}
func TestRuleMovedBetweenGroups(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")

View file

@ -1777,7 +1777,9 @@ loop:
if err == nil {
sl.cache.forEachStale(func(lset labels.Labels) bool {
// Series no longer exposed, mark it stale.
app.SetHints(&storage.AppendHints{DiscardOutOfOrder: true})
_, err = app.Append(0, lset, defTime, math.Float64frombits(value.StaleNaN))
app.SetHints(nil)
switch {
case errors.Is(err, storage.ErrOutOfOrderSample), errors.Is(err, storage.ErrDuplicateSampleForTimestamp):
// Do not count these in logging, as this is expected if a target
@ -1883,7 +1885,7 @@ func (sl *scrapeLoop) report(app storage.Appender, start time.Time, duration tim
func (sl *scrapeLoop) reportStale(app storage.Appender, start time.Time) (err error) {
ts := timestamp.FromTime(start)
app.SetHints(&storage.AppendHints{DiscardOutOfOrder: true})
stale := math.Float64frombits(value.StaleNaN)
b := labels.NewBuilder(labels.EmptyLabels())

View file

@ -151,6 +151,7 @@ type fanoutAppender struct {
func (f *fanoutAppender) SetHints(hints *AppendHints) {
panic("unimplemented")
}
func (f *fanoutAppender) Append(ref SeriesRef, l labels.Labels, t int64, v float64) (SeriesRef, error) {
ref, err := f.primary.Append(ref, l, t, v)
if err != nil {

View file

@ -831,9 +831,11 @@ func (m *mockAppendable) Appender(_ context.Context) storage.Appender {
}
return m
}
func (m *mockAppendable) SetHints(hints *storage.AppendHints) {
panic("unimplemented")
}
func (m *mockAppendable) Append(_ storage.SeriesRef, l labels.Labels, t int64, v float64) (storage.SeriesRef, error) {
if m.appendSampleErr != nil {
return 0, m.appendSampleErr

View file

@ -329,6 +329,7 @@ type headAppender struct {
func (a *headAppender) SetHints(hints *storage.AppendHints) {
a.hints = hints
}
func (a *headAppender) Append(ref storage.SeriesRef, lset labels.Labels, t int64, v float64) (storage.SeriesRef, error) {
// For OOO inserts, this restriction is irrelevant and will be checked later once we confirm the sample is an in-order append.
// If OOO inserts are disabled, we may as well as check this as early as we can and avoid more work.

View file

@ -50,7 +50,7 @@ func NewWithError() (*TestStorage, error) {
opts.MinBlockDuration = int64(24 * time.Hour / time.Millisecond)
opts.MaxBlockDuration = int64(24 * time.Hour / time.Millisecond)
opts.RetentionDuration = 0
//opts.EnableNativeHistograms = true
opts.EnableNativeHistograms = true
opts.OutOfOrderTimeWindow = 600000
db, err := tsdb.Open(dir, nil, nil, opts, tsdb.NewDBStats())
if err != nil {