Skip to content

Commit 599ccc6

Browse files
billprovinceskrdgraphJoshua Goldstein
authored
fix(test): The new test case PagebufferReader5 introduced an error. (#1936)
## Problem Fixes DGRAPHCORE-199 The intended fix for the CI issue for randomly getting EOF failures in PagebufferReader2 test introduced the test case FixPagebufferReader5 -- intended to avoid regressions. However, it did something that is not expected by the PageBuffer struct: it created a new PageBufferReader based on an empty PageBuffer. It seems that this is not allowed. ## Solution Fix the test case for PagebufferReader5 by no longer attempting to create a new PageBufferReader based on an empty PageBuffer. ### Note The CI build will still fail to allow this to pass because it will continue to use the prior version of the tests without the fix. However, locally tested, I get this result: ~/gitspace/github.com/dgraph-io/badger/y$ go test -run PagebufferReader5 PASS ok github.com/dgraph-io/badger/v4/y 0.335s --------- Co-authored-by: skrdgraph <[email protected]> Co-authored-by: Joshua Goldstein <[email protected]>
1 parent 2c431a9 commit 599ccc6

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

y/y_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,16 @@ func TestPagebufferReader4(t *testing.T) {
262262
// Test when reading into 0 length readBuffer
263263
func TestPagebufferReader5(t *testing.T) {
264264
b := NewPageBuffer(32)
265-
readerWhenEmptyPageBuffer := b.NewReaderAt(0)
266-
267-
readBuffer := []byte{} // Intentionally empty readBuffer.
268-
n, err := readerWhenEmptyPageBuffer.Read(readBuffer)
269-
require.NoError(t, err, "reading into empty buffer should return no error")
270-
require.Equal(t, 0, n, "read into empty buffer should return 0 bytes")
271-
272265
var wb [20]byte
273266
rand.Read(wb[:])
274-
n, err = b.Write(wb[:])
267+
n, err := b.Write(wb[:])
275268
require.Equal(t, n, len(wb), "length of buffer and length written should be equal")
276269
require.NoError(t, err, "unable to write bytes to buffer")
277270

278-
readerWhenNonEmptyPageBuffer := b.NewReaderAt(0)
279-
n, err = readerWhenNonEmptyPageBuffer.Read(readBuffer)
271+
reader := b.NewReaderAt(0)
272+
273+
readBuffer := []byte{} // Intentionally empty readBuffer.
274+
n, err = reader.Read(readBuffer)
280275
require.NoError(t, err, "reading into empty buffer should return no error")
281276
require.Equal(t, 0, n, "read into empty buffer should return 0 bytes")
282277
}

0 commit comments

Comments
 (0)