Fix Instance type during benchmarks. (#3147)

- The benchmark initialization function was not taking into account the
  instance type (FS/XL), was using XL ObjectLayer even for FS
  benchmarks.
- This was leading to incorrect benchmark results for FS related
  benchmarks.
- The fix takes into account the instance type (FS/XL) and correctly
  returns FS backend for FS benchmarks.
master
Karthic Rao 8 years ago committed by Harshavardhana
parent 4b302173ae
commit 8bffa78f7f
  1. 15
      cmd/benchmark-utils_test.go
  2. 20
      cmd/test-utils_test.go

@ -30,7 +30,18 @@ import (
// Prepare benchmark backend // Prepare benchmark backend
func prepareBenchmarkBackend(instanceType string) (ObjectLayer, []string, error) { func prepareBenchmarkBackend(instanceType string) (ObjectLayer, []string, error) {
nDisks := 16 var nDisks int
switch instanceType {
// Total number of disks for FS backend is set to 1.
case FSTestStr:
nDisks = 1
// Total number of disks for FS backend is set to 16.
case XLTestStr:
nDisks = 16
default:
nDisks = 1
}
// get `nDisks` random disks.
disks, err := getRandomDisks(nDisks) disks, err := getRandomDisks(nDisks)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -39,11 +50,11 @@ func prepareBenchmarkBackend(instanceType string) (ObjectLayer, []string, error)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
// initialize object layer.
obj, _, err := initObjectLayer(endpoints, nil) obj, _, err := initObjectLayer(endpoints, nil)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
return obj, disks, nil return obj, disks, nil
} }

@ -104,10 +104,10 @@ type TestErrHandler interface {
} }
const ( const (
// singleNodeTestStr is the string which is used as notation for Single node ObjectLayer in the unit tests. // FSTestStr is the string which is used as notation for Single node ObjectLayer in the unit tests.
singleNodeTestStr string = "FS" FSTestStr string = "FS"
// xLTestStr is the string which is used as notation for XL ObjectLayer in the unit tests. // XLTestStr is the string which is used as notation for XL ObjectLayer in the unit tests.
xLTestStr string = "XL" XLTestStr string = "XL"
) )
const letterBytes = "abcdefghijklmnopqrstuvwxyz01234569" const letterBytes = "abcdefghijklmnopqrstuvwxyz01234569"
@ -1850,7 +1850,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
} }
credentials := serverConfig.GetCredential() credentials := serverConfig.GetCredential()
// Executing the object layer tests for single node setup. // Executing the object layer tests for single node setup.
objAPITest(objLayer, singleNodeTestStr, bucketFS, fsAPIRouter, credentials, t) objAPITest(objLayer, FSTestStr, bucketFS, fsAPIRouter, credentials, t)
objLayer, xlDisks, err := prepareXL() objLayer, xlDisks, err := prepareXL()
if err != nil { if err != nil {
@ -1862,7 +1862,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
} }
credentials = serverConfig.GetCredential() credentials = serverConfig.GetCredential()
// Executing the object layer tests for XL. // Executing the object layer tests for XL.
objAPITest(objLayer, xLTestStr, bucketXL, xlAPIRouter, credentials, t) objAPITest(objLayer, XLTestStr, bucketXL, xlAPIRouter, credentials, t)
// clean up the temporary test backend. // clean up the temporary test backend.
removeRoots(append(xlDisks, fsDir, rootPath)) removeRoots(append(xlDisks, fsDir, rootPath))
} }
@ -1893,14 +1893,14 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
t.Fatalf("Initialization of object layer failed for single node setup: %s", err) t.Fatalf("Initialization of object layer failed for single node setup: %s", err)
} }
// Executing the object layer tests for single node setup. // Executing the object layer tests for single node setup.
objTest(objLayer, singleNodeTestStr, t) objTest(objLayer, FSTestStr, t)
objLayer, fsDirs, err := prepareXL() objLayer, fsDirs, err := prepareXL()
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)
} }
// Executing the object layer tests for XL. // Executing the object layer tests for XL.
objTest(objLayer, xLTestStr, t) objTest(objLayer, XLTestStr, t)
defer removeRoots(append(fsDirs, fsDir)) defer removeRoots(append(fsDirs, fsDir))
} }
@ -1912,7 +1912,7 @@ func ExecObjectLayerDiskAlteredTest(t *testing.T, objTest objTestDiskNotFoundTyp
t.Fatalf("Initialization of object layer failed for XL setup: %s", err) t.Fatalf("Initialization of object layer failed for XL setup: %s", err)
} }
// Executing the object layer tests for XL. // Executing the object layer tests for XL.
objTest(objLayer, xLTestStr, fsDirs, t) objTest(objLayer, XLTestStr, fsDirs, t)
defer removeRoots(fsDirs) defer removeRoots(fsDirs)
} }
@ -1936,7 +1936,7 @@ func ExecObjectLayerStaleFilesTest(t *testing.T, objTest objTestStaleFilesType)
t.Fatalf("Initialization of object layer failed for XL setup: %s", err) t.Fatalf("Initialization of object layer failed for XL setup: %s", err)
} }
// Executing the object layer tests for XL. // Executing the object layer tests for XL.
objTest(objLayer, xLTestStr, erasureDisks, t) objTest(objLayer, XLTestStr, erasureDisks, t)
defer removeRoots(erasureDisks) defer removeRoots(erasureDisks)
} }

Loading…
Cancel
Save