From 8bffa78f7f667b97899d81a6c1a1473fd1456d76 Mon Sep 17 00:00:00 2001 From: Karthic Rao Date: Tue, 1 Nov 2016 22:51:16 +0530 Subject: [PATCH] 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. --- cmd/benchmark-utils_test.go | 15 +++++++++++++-- cmd/test-utils_test.go | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cmd/benchmark-utils_test.go b/cmd/benchmark-utils_test.go index 7da3600c0..bf05a2489 100644 --- a/cmd/benchmark-utils_test.go +++ b/cmd/benchmark-utils_test.go @@ -30,7 +30,18 @@ import ( // Prepare benchmark backend 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) if err != nil { return nil, nil, err @@ -39,11 +50,11 @@ func prepareBenchmarkBackend(instanceType string) (ObjectLayer, []string, error) if err != nil { return nil, nil, err } + // initialize object layer. obj, _, err := initObjectLayer(endpoints, nil) if err != nil { return nil, nil, err } - return obj, disks, nil } diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index 36e04ed88..f7ef8dca8 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -104,10 +104,10 @@ type TestErrHandler interface { } const ( - // singleNodeTestStr is the string which is used as notation for Single node ObjectLayer in the unit tests. - singleNodeTestStr string = "FS" - // xLTestStr is the string which is used as notation for XL ObjectLayer in the unit tests. - xLTestStr string = "XL" + // FSTestStr is the string which is used as notation for Single node ObjectLayer in the unit tests. + FSTestStr string = "FS" + // XLTestStr is the string which is used as notation for XL ObjectLayer in the unit tests. + XLTestStr string = "XL" ) const letterBytes = "abcdefghijklmnopqrstuvwxyz01234569" @@ -1850,7 +1850,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [ } credentials := serverConfig.GetCredential() // 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() if err != nil { @@ -1862,7 +1862,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [ } credentials = serverConfig.GetCredential() // 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. 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) } // Executing the object layer tests for single node setup. - objTest(objLayer, singleNodeTestStr, t) + objTest(objLayer, FSTestStr, t) objLayer, fsDirs, err := prepareXL() if err != nil { t.Fatalf("Initialization of object layer failed for XL setup: %s", err) } // Executing the object layer tests for XL. - objTest(objLayer, xLTestStr, t) + objTest(objLayer, XLTestStr, t) 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) } // Executing the object layer tests for XL. - objTest(objLayer, xLTestStr, fsDirs, t) + objTest(objLayer, XLTestStr, fsDirs, t) 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) } // Executing the object layer tests for XL. - objTest(objLayer, xLTestStr, erasureDisks, t) + objTest(objLayer, XLTestStr, erasureDisks, t) defer removeRoots(erasureDisks) }