mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 13:40:22 +03:00
XL: Refactor usage of reduceErrs and consistent behavior. (#2240)
This refactor is also needed in lieu of our quorum requirement change for the newly understood logic behind klauspost/reedsolom implementation.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
f67c930731
commit
cef26fd6ea
+27
-10
@@ -20,23 +20,40 @@ import "testing"
|
||||
|
||||
// Test for reduceErrs.
|
||||
func TestReduceErrs(t *testing.T) {
|
||||
// List all of all test cases to validate various cases of reduce errors.
|
||||
testCases := []struct {
|
||||
errs []error
|
||||
err error
|
||||
count int
|
||||
errs []error
|
||||
ignoredErrs []error
|
||||
err error
|
||||
}{
|
||||
{[]error{errDiskNotFound, errDiskNotFound, errDiskFull}, errDiskNotFound, 2},
|
||||
{[]error{errDiskFull, errDiskNotFound, nil, nil}, nil, 2},
|
||||
{[]error{}, nil, 0},
|
||||
// Validate if have reduced properly.
|
||||
{[]error{
|
||||
errDiskNotFound,
|
||||
errDiskNotFound,
|
||||
errDiskFull,
|
||||
}, []error{}, errDiskNotFound},
|
||||
// Validate if have no consensus.
|
||||
{[]error{
|
||||
errDiskFull,
|
||||
errDiskNotFound,
|
||||
nil, nil,
|
||||
}, []error{}, nil},
|
||||
// Validate if have consensus and errors ignored.
|
||||
{[]error{
|
||||
errVolumeNotFound,
|
||||
errVolumeNotFound,
|
||||
errVolumeNotFound,
|
||||
errDiskNotFound,
|
||||
errDiskNotFound,
|
||||
}, []error{errDiskNotFound}, errVolumeNotFound},
|
||||
{[]error{}, []error{}, nil},
|
||||
}
|
||||
// Validates list of all the testcases for returning valid errors.
|
||||
for i, testCase := range testCases {
|
||||
gotMax, gotErr := reduceErrs(testCase.errs)
|
||||
gotErr := reduceErrs(testCase.errs, testCase.ignoredErrs)
|
||||
if testCase.err != gotErr {
|
||||
t.Errorf("Test %d : expected %s, got %s", i+1, testCase.err, gotErr)
|
||||
}
|
||||
if testCase.count != gotMax {
|
||||
t.Errorf("Test %d : expected %d, got %d", i+1, testCase.count, gotMax)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user