-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
verifier: allow to tolerate data loss
This mode allows to verify redpanda when write caching is enabled. In addition to tolerating data loss we also record and export to the /status endpoint the number of offsets/records that are considered lost from the point of view of the verifier.
- Loading branch information
1 parent
e35dc1d
commit 99de2ad
Showing
8 changed files
with
201 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package verifier_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/redpanda-data/kgo-verifier/pkg/worker/verifier" | ||
) | ||
|
||
func TestOffsetRanges(t *testing.T) { | ||
r := verifier.OffsetRanges{} | ||
r.Insert(0) | ||
r.Insert(1) | ||
r.Insert(2) | ||
r.Insert(10) | ||
} | ||
|
||
func TestOffsetRangesOutOfOrder(t *testing.T) { | ||
r := verifier.OffsetRanges{} | ||
r.Insert(0) | ||
r.Insert(4) | ||
r.Insert(5) | ||
r.Insert(6) | ||
r.Insert(10) | ||
|
||
func() { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
t.Errorf("Expected to panic on out of order insert") | ||
} | ||
}() | ||
r.Insert(3) | ||
}() | ||
|
||
} | ||
|
||
func TestOffsetRangesTolerateOutOfOrderContinuous(t *testing.T) { | ||
r := verifier.OffsetRanges{ | ||
TolerateDataLoss: true, | ||
} | ||
r.Insert(0) | ||
r.Insert(4) | ||
r.Insert(5) | ||
r.Insert(6) | ||
r.Insert(10) | ||
|
||
// This will truncate the ranges. | ||
r.Insert(5) | ||
|
||
expected := verifier.OffsetRanges{ | ||
TolerateDataLoss: true, | ||
} | ||
expected.Insert(0) | ||
expected.Insert(4) | ||
expected.Insert(5) | ||
|
||
if !reflect.DeepEqual(expected, r) { | ||
t.Errorf("Expected %v, got %v", expected, r.Ranges) | ||
} | ||
} | ||
|
||
func TestOffsetRangesTolerateOutOfOrderGaps(t *testing.T) { | ||
r := verifier.OffsetRanges{ | ||
TolerateDataLoss: true, | ||
} | ||
r.Insert(0) | ||
r.Insert(3) | ||
r.Insert(5) | ||
r.Insert(7) | ||
r.Insert(10) | ||
|
||
// This will truncate the ranges. | ||
r.Insert(5) | ||
|
||
expected := verifier.OffsetRanges{ | ||
TolerateDataLoss: true, | ||
} | ||
expected.Insert(0) | ||
expected.Insert(3) | ||
expected.Insert(5) | ||
|
||
if !reflect.DeepEqual(expected, r) { | ||
t.Errorf("Expected %v, got %v", expected, r.Ranges) | ||
} | ||
} | ||
|
||
func TestOffsetRangesTolerateOutOfOrderInsideGap(t *testing.T) { | ||
r := verifier.OffsetRanges{ | ||
TolerateDataLoss: true, | ||
} | ||
r.Insert(0) | ||
r.Insert(3) | ||
r.Insert(7) | ||
r.Insert(10) | ||
|
||
// This will truncate the ranges. | ||
r.Insert(5) | ||
|
||
expected := verifier.OffsetRanges{ | ||
TolerateDataLoss: true, | ||
} | ||
expected.Insert(0) | ||
expected.Insert(3) | ||
expected.Insert(5) | ||
|
||
if !reflect.DeepEqual(expected, r) { | ||
t.Errorf("Expected %v, got %v", expected, r) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters