sets: Correctly set IsTruncated in listing (#7675)

IsTruncated should not be set to true if there is no further
possible entries beyond maxKeys.

This commit will also move wide testing on object API from xl
to xl sets.
master
Anis Elleuch 6 years ago committed by kannappanr
parent c4c79f61ce
commit 158b8c2e86
  1. 6
      cmd/test-utils_test.go
  2. 19
      cmd/xl-sets.go

@ -174,7 +174,7 @@ func prepareFS() (ObjectLayer, string, error) {
return obj, fsDirs[0], nil return obj, fsDirs[0], nil
} }
func prepareXL32() (ObjectLayer, []string, error) { func prepareXLSets32() (ObjectLayer, []string, error) {
fsDirs1, err := getRandomDisks(16) fsDirs1, err := getRandomDisks(16)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -1704,7 +1704,7 @@ func prepareTestBackend(instanceType string) (ObjectLayer, []string, error) {
switch instanceType { switch instanceType {
// Total number of disks for XL sets backend is set to 32. // Total number of disks for XL sets backend is set to 32.
case XLSetsTestStr: case XLSetsTestStr:
return prepareXL32() return prepareXLSets32()
// Total number of disks for XL backend is set to 16. // Total number of disks for XL backend is set to 16.
case XLTestStr: case XLTestStr:
return prepareXL16() return prepareXL16()
@ -1986,7 +1986,7 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
// Executing the object layer tests for single node setup. // Executing the object layer tests for single node setup.
objTest(objLayer, FSTestStr, t) objTest(objLayer, FSTestStr, t)
objLayer, fsDirs, err := prepareXL16() objLayer, fsDirs, err := prepareXLSets32()
if err != nil { if err != nil {
t.Fatalf("Initialization of object layer failed for XL setup: %s", err) t.Fatalf("Initialization of object layer failed for XL setup: %s", err)
} }

@ -858,10 +858,21 @@ func leastEntry(entriesCh []FileInfoCh, readQuorum int) (FileInfo, bool) {
// mergeEntriesCh - merges FileInfo channel to entries upto maxKeys. // mergeEntriesCh - merges FileInfo channel to entries upto maxKeys.
func mergeEntriesCh(entriesCh []FileInfoCh, maxKeys int, readQuorum int) (entries FilesInfo) { func mergeEntriesCh(entriesCh []FileInfoCh, maxKeys int, readQuorum int) (entries FilesInfo) {
for i := 0; i < maxKeys; { var i = 0
var fi FileInfo for {
fi, entries.IsTruncated = leastEntry(entriesCh, readQuorum) fi, valid := leastEntry(entriesCh, readQuorum)
if !entries.IsTruncated { if !valid {
break
}
if i == maxKeys {
entries.IsTruncated = true
// Re-insert the last entry so it can be
// listed in the next listing iteration.
for j := range entriesCh {
if !entriesCh[j].Valid {
entriesCh[j].Push(fi)
}
}
break break
} }
entries.Files = append(entries.Files, fi) entries.Files = append(entries.Files, fi)

Loading…
Cancel
Save