Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
thepalbi committed Jul 25, 2023
1 parent e27e389 commit be201ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
22 changes: 3 additions & 19 deletions component/common/loki/wal/watcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wal

import (
"errors"
"fmt"
"io"
"math"
Expand Down Expand Up @@ -190,7 +191,7 @@ func (w *Watcher) watch(segmentNum int) error {
}

// io.EOF error are non-fatal since we are tailing the wal
if errorCause(err) != io.EOF {
if errors.Unwrap(err) != io.EOF {
return err
}

Expand All @@ -215,7 +216,7 @@ func (w *Watcher) watch(segmentNum int) error {
}

// io.EOF error are non-fatal since we are tailing the wal
if errorCause(err) != io.EOF {
if errors.Unwrap(err) != io.EOF {
return err
}

Expand Down Expand Up @@ -348,20 +349,3 @@ func readSegmentNumbers(dir string) ([]int, error) {
}
return refs, nil
}

// errorCause gets the underlying error case, if this implements the causer interface.
// Inlining to avoid using deny-listed dependency.
func errorCause(err error) error {
type causer interface {
Cause() error
}

for err != nil {
cause, ok := err.(causer)
if !ok {
break
}
err = cause.Cause()
}
return err
}
2 changes: 1 addition & 1 deletion component/common/loki/wal/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ var cases = map[string]watcherTest{
require.Eventually(t, func() bool {
return res.writeTo.ReadEntries.Length() == 3
}, time.Second*10, time.Second, "expected watcher to catch up with written entries")
defer res.writeTo.ReadEntries.DoneIterate()
for _, readEntry := range res.writeTo.ReadEntries.StartIterate() {
require.Contains(t, lines, readEntry.Line, "not expected log line")
}
res.writeTo.ReadEntries.DoneIterate()

err := res.nextWALSegment()
require.NoError(t, err, "expected no error when moving to next wal segment")
Expand Down

0 comments on commit be201ab

Please sign in to comment.