tests: Fix the sopradic test failure in TestListObjectPartsDiskNotFound (#4107)

getBucketInfo() should keep track errors ignored,
such that in a situation where all errors were
ignored we need to reduce the errors using readQuorum
to get a consistent error value.

This is the problem we see with DiskNotFound test
disks are randomly removed.

Fixes #4095
This commit is contained in:
Harshavardhana 2017-04-12 15:38:35 -07:00 committed by GitHub
parent e4bd882f11
commit 6683247080
2 changed files with 15 additions and 7 deletions

View File

@ -1457,7 +1457,7 @@ func testListObjectPartsDiskNotFound(obj ObjectLayer, instanceType string, disks
// Failed as expected, but does it fail for the expected reason.
if actualErr != nil && !testCase.shouldPass {
if !strings.Contains(actualErr.Error(), testCase.expectedErr.Error()) {
t.Errorf("Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, instanceType, testCase.expectedErr.Error(), actualErr.Error())
t.Errorf("Test %d: %s: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, instanceType, testCase.expectedErr, actualErr)
}
}
// Passes as expected, but asserting the results.

View File

@ -113,27 +113,34 @@ func undoMakeBucket(storageDisks []StorageAPI, bucket string) {
// getBucketInfo - returns the BucketInfo from one of the load balanced disks.
func (xl xlObjects) getBucketInfo(bucketName string) (bucketInfo BucketInfo, err error) {
var bucketErrs []error
for _, disk := range xl.getLoadBalancedDisks() {
if disk == nil {
bucketErrs = append(bucketErrs, errDiskNotFound)
continue
}
var volInfo VolInfo
volInfo, err = disk.StatVol(bucketName)
if err == nil {
volInfo, serr := disk.StatVol(bucketName)
if serr == nil {
bucketInfo = BucketInfo{
Name: volInfo.Name,
Created: volInfo.Created,
}
return bucketInfo, nil
}
err = traceError(err)
err = traceError(serr)
// For any reason disk went offline continue and pick the next one.
if isErrIgnored(err, bucketMetadataOpIgnoredErrs...) {
bucketErrs = append(bucketErrs, err)
continue
}
break
// Any error which cannot be ignored, we return quickly.
return BucketInfo{}, err
}
return BucketInfo{}, err
// If all our errors were ignored, then we try to
// reduce to one error based on read quorum.
// `nil` is deliberately passed for ignoredErrs
// because these errors were already ignored.
return BucketInfo{}, reduceReadQuorumErrs(bucketErrs, nil, xl.readQuorum)
}
// GetBucketInfo - returns BucketInfo for a bucket.
@ -180,6 +187,7 @@ func (xl xlObjects) listBuckets() (bucketsInfo []BucketInfo, err error) {
}
return bucketsInfo, nil
}
err = traceError(err)
// Ignore any disks not found.
if isErrIgnored(err, bucketMetadataOpIgnoredErrs...) {
continue