You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
516 lines
13 KiB
516 lines
13 KiB
9 years ago
|
/*
|
||
6 years ago
|
* MinIO Cloud Storage, (C) 2018 MinIO, Inc.
|
||
9 years ago
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
8 years ago
|
package cmd
|
||
9 years ago
|
|
||
8 years ago
|
import (
|
||
7 years ago
|
"encoding/json"
|
||
|
"io/ioutil"
|
||
8 years ago
|
"os"
|
||
7 years ago
|
"reflect"
|
||
8 years ago
|
"testing"
|
||
|
)
|
||
9 years ago
|
|
||
7 years ago
|
// Test get offline/online uuids.
|
||
|
func TestGetUUIDs(t *testing.T) {
|
||
5 years ago
|
fmtV2 := newFormatErasureV3(4, 16)
|
||
|
formats := make([]*formatErasureV3, 64)
|
||
9 years ago
|
|
||
7 years ago
|
for i := 0; i < 4; i++ {
|
||
|
for j := 0; j < 16; j++ {
|
||
|
newFormat := *fmtV2
|
||
5 years ago
|
newFormat.Erasure.This = fmtV2.Erasure.Sets[i][j]
|
||
7 years ago
|
formats[i*16+j] = &newFormat
|
||
|
}
|
||
|
}
|
||
8 years ago
|
|
||
7 years ago
|
gotCount := len(getOnlineUUIDs(fmtV2, formats))
|
||
|
if gotCount != 64 {
|
||
|
t.Errorf("Expected online count '64', got '%d'", gotCount)
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
for i := 0; i < 4; i++ {
|
||
|
for j := 0; j < 16; j++ {
|
||
|
if j < 4 {
|
||
|
formats[i*16+j] = nil
|
||
|
}
|
||
|
}
|
||
|
}
|
||
8 years ago
|
|
||
7 years ago
|
gotCount = len(getOnlineUUIDs(fmtV2, formats))
|
||
|
if gotCount != 48 {
|
||
|
t.Errorf("Expected online count '48', got '%d'", gotCount)
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
gotCount = len(getOfflineUUIDs(fmtV2, formats))
|
||
|
if gotCount != 16 {
|
||
|
t.Errorf("Expected offline count '16', got '%d'", gotCount)
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
markUUIDsOffline(fmtV2, formats)
|
||
|
gotCount = 0
|
||
5 years ago
|
for i := range fmtV2.Erasure.Sets {
|
||
|
for j := range fmtV2.Erasure.Sets[i] {
|
||
|
if fmtV2.Erasure.Sets[i][j] == offlineDiskUUID {
|
||
7 years ago
|
gotCount++
|
||
|
}
|
||
8 years ago
|
}
|
||
|
}
|
||
7 years ago
|
if gotCount != 16 {
|
||
|
t.Errorf("Expected offline count '16', got '%d'", gotCount)
|
||
|
}
|
||
8 years ago
|
}
|
||
|
|
||
5 years ago
|
// tests fixFormatErasureV3 - fix format.json on all disks.
|
||
7 years ago
|
func TestFixFormatV3(t *testing.T) {
|
||
5 years ago
|
erasureDirs, err := getRandomDisks(8)
|
||
7 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
5 years ago
|
for _, erasureDir := range erasureDirs {
|
||
|
defer os.RemoveAll(erasureDir)
|
||
7 years ago
|
}
|
||
5 years ago
|
endpoints := mustGetNewEndpoints(erasureDirs...)
|
||
7 years ago
|
|
||
5 years ago
|
storageDisks, errs := initStorageDisksWithErrors(endpoints)
|
||
|
for _, err := range errs {
|
||
|
if err != nil && err != errDiskNotFound {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
format := newFormatErasureV3(1, 8)
|
||
|
formats := make([]*formatErasureV3, 8)
|
||
7 years ago
|
|
||
|
for j := 0; j < 8; j++ {
|
||
5 years ago
|
newFormat := format.Clone()
|
||
5 years ago
|
newFormat.Erasure.This = format.Erasure.Sets[0][j]
|
||
5 years ago
|
formats[j] = newFormat
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
if err = initErasureMetaVolumesInLocalDisks(storageDisks, formats); err != nil {
|
||
7 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
formats[1] = nil
|
||
5 years ago
|
expThis := formats[2].Erasure.This
|
||
|
formats[2].Erasure.This = ""
|
||
|
if err := fixFormatErasureV3(storageDisks, endpoints, formats); err != nil {
|
||
7 years ago
|
t.Fatal(err)
|
||
|
}
|
||
7 years ago
|
|
||
5 years ago
|
newFormats, errs := loadFormatErasureAll(storageDisks, false)
|
||
7 years ago
|
for _, err := range errs {
|
||
7 years ago
|
if err != nil && err != errUnformattedDisk {
|
||
7 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
}
|
||
5 years ago
|
gotThis := newFormats[2].Erasure.This
|
||
7 years ago
|
if expThis != gotThis {
|
||
|
t.Fatalf("expected uuid %s, got %s", expThis, gotThis)
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
// tests formatErasureV3ThisEmpty conditions.
|
||
|
func TestFormatErasureEmpty(t *testing.T) {
|
||
|
format := newFormatErasureV3(1, 16)
|
||
|
formats := make([]*formatErasureV3, 16)
|
||
7 years ago
|
|
||
|
for j := 0; j < 16; j++ {
|
||
5 years ago
|
newFormat := format.Clone()
|
||
5 years ago
|
newFormat.Erasure.This = format.Erasure.Sets[0][j]
|
||
5 years ago
|
formats[j] = newFormat
|
||
7 years ago
|
}
|
||
|
|
||
|
// empty format to indicate disk not found, but this
|
||
|
// empty should return false.
|
||
|
formats[0] = nil
|
||
|
|
||
5 years ago
|
if ok := formatErasureV3ThisEmpty(formats); ok {
|
||
7 years ago
|
t.Fatalf("expected value false, got %t", ok)
|
||
|
}
|
||
|
|
||
5 years ago
|
formats[2].Erasure.This = ""
|
||
|
if ok := formatErasureV3ThisEmpty(formats); !ok {
|
||
7 years ago
|
t.Fatalf("expected value true, got %t", ok)
|
||
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
// Tests xl format migration.
|
||
5 years ago
|
func TestFormatErasureMigrate(t *testing.T) {
|
||
7 years ago
|
// Get test root.
|
||
|
rootPath, err := getTestRoot()
|
||
8 years ago
|
if err != nil {
|
||
7 years ago
|
t.Fatal(err)
|
||
8 years ago
|
}
|
||
7 years ago
|
defer os.RemoveAll(rootPath)
|
||
8 years ago
|
|
||
5 years ago
|
m := &formatErasureV1{}
|
||
|
m.Format = formatBackendErasure
|
||
7 years ago
|
m.Version = formatMetaVersionV1
|
||
5 years ago
|
m.Erasure.Version = formatErasureVersionV1
|
||
|
m.Erasure.Disk = mustGetUUID()
|
||
|
m.Erasure.JBOD = []string{m.Erasure.Disk, mustGetUUID(), mustGetUUID(), mustGetUUID()}
|
||
8 years ago
|
|
||
7 years ago
|
b, err := json.Marshal(m)
|
||
8 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
7 years ago
|
if err = os.MkdirAll(pathJoin(rootPath, minioMetaBucket), os.FileMode(0755)); err != nil {
|
||
8 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
7 years ago
|
if err = ioutil.WriteFile(pathJoin(rootPath, minioMetaBucket, formatConfigFile), b, os.FileMode(0644)); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
8 years ago
|
|
||
5 years ago
|
if err = formatErasureMigrate(rootPath); err != nil {
|
||
8 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
5 years ago
|
migratedVersion, err := formatGetBackendErasureVersion(pathJoin(rootPath, minioMetaBucket, formatConfigFile))
|
||
7 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
if migratedVersion != formatErasureVersionV3 {
|
||
|
t.Fatalf("expected version: %s, got: %s", formatErasureVersionV3, migratedVersion)
|
||
7 years ago
|
}
|
||
|
|
||
|
b, err = ioutil.ReadFile(pathJoin(rootPath, minioMetaBucket, formatConfigFile))
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
5 years ago
|
formatV3 := &formatErasureV3{}
|
||
7 years ago
|
if err = json.Unmarshal(b, formatV3); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
5 years ago
|
if formatV3.Erasure.This != m.Erasure.Disk {
|
||
|
t.Fatalf("expected disk uuid: %s, got: %s", m.Erasure.Disk, formatV3.Erasure.This)
|
||
7 years ago
|
}
|
||
5 years ago
|
if len(formatV3.Erasure.Sets) != 1 {
|
||
|
t.Fatalf("expected single set after migrating from v1 to v3, but found %d", len(formatV3.Erasure.Sets))
|
||
7 years ago
|
}
|
||
5 years ago
|
if !reflect.DeepEqual(formatV3.Erasure.Sets[0], m.Erasure.JBOD) {
|
||
|
t.Fatalf("expected disk uuid: %v, got: %v", m.Erasure.JBOD, formatV3.Erasure.Sets[0])
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
m = &formatErasureV1{}
|
||
7 years ago
|
m.Format = "unknown"
|
||
|
m.Version = formatMetaVersionV1
|
||
5 years ago
|
m.Erasure.Version = formatErasureVersionV1
|
||
|
m.Erasure.Disk = mustGetUUID()
|
||
|
m.Erasure.JBOD = []string{m.Erasure.Disk, mustGetUUID(), mustGetUUID(), mustGetUUID()}
|
||
7 years ago
|
|
||
|
b, err = json.Marshal(m)
|
||
|
if err != nil {
|
||
8 years ago
|
t.Fatal(err)
|
||
|
}
|
||
7 years ago
|
|
||
|
if err = ioutil.WriteFile(pathJoin(rootPath, minioMetaBucket, formatConfigFile), b, os.FileMode(0644)); err != nil {
|
||
8 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
5 years ago
|
if err = formatErasureMigrate(rootPath); err == nil {
|
||
7 years ago
|
t.Fatal("Expected to fail with unexpected backend format")
|
||
|
}
|
||
8 years ago
|
|
||
5 years ago
|
m = &formatErasureV1{}
|
||
|
m.Format = formatBackendErasure
|
||
7 years ago
|
m.Version = formatMetaVersionV1
|
||
5 years ago
|
m.Erasure.Version = "30"
|
||
|
m.Erasure.Disk = mustGetUUID()
|
||
|
m.Erasure.JBOD = []string{m.Erasure.Disk, mustGetUUID(), mustGetUUID(), mustGetUUID()}
|
||
8 years ago
|
|
||
7 years ago
|
b, err = json.Marshal(m)
|
||
8 years ago
|
if err != nil {
|
||
7 years ago
|
t.Fatal(err)
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
if err = ioutil.WriteFile(pathJoin(rootPath, minioMetaBucket, formatConfigFile), b, os.FileMode(0644)); err != nil {
|
||
|
t.Fatal(err)
|
||
8 years ago
|
}
|
||
|
|
||
5 years ago
|
if err = formatErasureMigrate(rootPath); err == nil {
|
||
7 years ago
|
t.Fatal("Expected to fail with unexpected backend format version number")
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
// Tests check format xl value.
|
||
5 years ago
|
func TestCheckFormatErasureValue(t *testing.T) {
|
||
9 years ago
|
testCases := []struct {
|
||
5 years ago
|
format *formatErasureV3
|
||
7 years ago
|
success bool
|
||
9 years ago
|
}{
|
||
5 years ago
|
// Invalid Erasure format version "2".
|
||
9 years ago
|
{
|
||
5 years ago
|
&formatErasureV3{
|
||
6 years ago
|
formatMetaV1: formatMetaV1{
|
||
|
Version: "2",
|
||
5 years ago
|
Format: "Erasure",
|
||
6 years ago
|
},
|
||
5 years ago
|
Erasure: struct {
|
||
7 years ago
|
Version string `json:"version"`
|
||
|
This string `json:"this"`
|
||
|
Sets [][]string `json:"sets"`
|
||
|
DistributionAlgo string `json:"distributionAlgo"`
|
||
|
}{
|
||
|
Version: "2",
|
||
|
},
|
||
|
},
|
||
|
false,
|
||
9 years ago
|
},
|
||
5 years ago
|
// Invalid Erasure format "Unknown".
|
||
9 years ago
|
{
|
||
5 years ago
|
&formatErasureV3{
|
||
6 years ago
|
formatMetaV1: formatMetaV1{
|
||
|
Version: "1",
|
||
|
Format: "Unknown",
|
||
|
},
|
||
5 years ago
|
Erasure: struct {
|
||
7 years ago
|
Version string `json:"version"`
|
||
|
This string `json:"this"`
|
||
|
Sets [][]string `json:"sets"`
|
||
|
DistributionAlgo string `json:"distributionAlgo"`
|
||
|
}{
|
||
|
Version: "2",
|
||
|
},
|
||
|
},
|
||
|
false,
|
||
9 years ago
|
},
|
||
5 years ago
|
// Invalid Erasure format version "0".
|
||
9 years ago
|
{
|
||
5 years ago
|
&formatErasureV3{
|
||
6 years ago
|
formatMetaV1: formatMetaV1{
|
||
|
Version: "1",
|
||
5 years ago
|
Format: "Erasure",
|
||
6 years ago
|
},
|
||
5 years ago
|
Erasure: struct {
|
||
7 years ago
|
Version string `json:"version"`
|
||
|
This string `json:"this"`
|
||
|
Sets [][]string `json:"sets"`
|
||
|
DistributionAlgo string `json:"distributionAlgo"`
|
||
|
}{
|
||
|
Version: "0",
|
||
|
},
|
||
|
},
|
||
|
false,
|
||
8 years ago
|
},
|
||
9 years ago
|
}
|
||
|
|
||
7 years ago
|
// Valid all test cases.
|
||
9 years ago
|
for i, testCase := range testCases {
|
||
5 years ago
|
if err := checkFormatErasureValue(testCase.format); err != nil && testCase.success {
|
||
7 years ago
|
t.Errorf("Test %d: Expected failure %s", i+1, err)
|
||
9 years ago
|
}
|
||
|
}
|
||
|
}
|
||
8 years ago
|
|
||
5 years ago
|
// Tests getFormatErasureInQuorum()
|
||
|
func TestGetFormatErasureInQuorumCheck(t *testing.T) {
|
||
7 years ago
|
setCount := 2
|
||
5 years ago
|
drivesPerSet := 16
|
||
8 years ago
|
|
||
5 years ago
|
format := newFormatErasureV3(setCount, drivesPerSet)
|
||
|
formats := make([]*formatErasureV3, 32)
|
||
7 years ago
|
|
||
7 years ago
|
for i := 0; i < setCount; i++ {
|
||
5 years ago
|
for j := 0; j < drivesPerSet; j++ {
|
||
|
newFormat := format.Clone()
|
||
5 years ago
|
newFormat.Erasure.This = format.Erasure.Sets[i][j]
|
||
5 years ago
|
formats[i*drivesPerSet+j] = newFormat
|
||
7 years ago
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
7 years ago
|
// Return a format from list of formats in quorum.
|
||
5 years ago
|
quorumFormat, err := getFormatErasureInQuorum(formats)
|
||
8 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
7 years ago
|
// Check if the reference format and input formats are same.
|
||
5 years ago
|
if err = formatErasureV3Check(quorumFormat, formats[0]); err != nil {
|
||
8 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
7 years ago
|
// QuorumFormat has .This field empty on purpose, expect a failure.
|
||
5 years ago
|
if err = formatErasureV3Check(formats[0], quorumFormat); err == nil {
|
||
7 years ago
|
t.Fatal("Unexpected success")
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
formats[0] = nil
|
||
5 years ago
|
quorumFormat, err = getFormatErasureInQuorum(formats)
|
||
8 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
7 years ago
|
badFormat := *quorumFormat
|
||
5 years ago
|
badFormat.Erasure.Sets = nil
|
||
|
if err = formatErasureV3Check(quorumFormat, &badFormat); err == nil {
|
||
7 years ago
|
t.Fatal("Unexpected success")
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
badFormatUUID := *quorumFormat
|
||
5 years ago
|
badFormatUUID.Erasure.Sets[0][0] = "bad-uuid"
|
||
|
if err = formatErasureV3Check(quorumFormat, &badFormatUUID); err == nil {
|
||
7 years ago
|
t.Fatal("Unexpected success")
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
badFormatSetSize := *quorumFormat
|
||
5 years ago
|
badFormatSetSize.Erasure.Sets[0] = nil
|
||
|
if err = formatErasureV3Check(quorumFormat, &badFormatSetSize); err == nil {
|
||
7 years ago
|
t.Fatal("Unexpected success")
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
for i := range formats {
|
||
|
if i < 17 {
|
||
|
formats[i] = nil
|
||
8 years ago
|
}
|
||
|
}
|
||
5 years ago
|
if _, err = getFormatErasureInQuorum(formats); err == nil {
|
||
7 years ago
|
t.Fatal("Unexpected success")
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
// Tests formatErasureGetDeploymentID()
|
||
|
func TestGetErasureID(t *testing.T) {
|
||
6 years ago
|
setCount := 2
|
||
5 years ago
|
drivesPerSet := 8
|
||
6 years ago
|
|
||
5 years ago
|
format := newFormatErasureV3(setCount, drivesPerSet)
|
||
|
formats := make([]*formatErasureV3, 16)
|
||
6 years ago
|
|
||
|
for i := 0; i < setCount; i++ {
|
||
5 years ago
|
for j := 0; j < drivesPerSet; j++ {
|
||
|
newFormat := format.Clone()
|
||
5 years ago
|
newFormat.Erasure.This = format.Erasure.Sets[i][j]
|
||
5 years ago
|
formats[i*drivesPerSet+j] = newFormat
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Return a format from list of formats in quorum.
|
||
5 years ago
|
quorumFormat, err := getFormatErasureInQuorum(formats)
|
||
6 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
// Check if the reference format and input formats are same.
|
||
|
var id string
|
||
5 years ago
|
if id, err = formatErasureGetDeploymentID(quorumFormat, formats); err != nil {
|
||
6 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if id == "" {
|
||
|
t.Fatal("ID cannot be empty.")
|
||
|
}
|
||
|
|
||
|
formats[0] = nil
|
||
5 years ago
|
if id, err = formatErasureGetDeploymentID(quorumFormat, formats); err != nil {
|
||
6 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
if id == "" {
|
||
|
t.Fatal("ID cannot be empty.")
|
||
|
}
|
||
|
|
||
5 years ago
|
formats[1].Erasure.Sets[0][0] = "bad-uuid"
|
||
|
if id, err = formatErasureGetDeploymentID(quorumFormat, formats); err != nil {
|
||
6 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if id == "" {
|
||
|
t.Fatal("ID cannot be empty.")
|
||
|
}
|
||
|
|
||
|
formats[2].ID = "bad-id"
|
||
5 years ago
|
if _, err = formatErasureGetDeploymentID(quorumFormat, formats); err != errCorruptedFormat {
|
||
6 years ago
|
t.Fatal("Unexpected Success")
|
||
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
// Initialize new format sets.
|
||
|
func TestNewFormatSets(t *testing.T) {
|
||
|
setCount := 2
|
||
5 years ago
|
drivesPerSet := 16
|
||
8 years ago
|
|
||
5 years ago
|
format := newFormatErasureV3(setCount, drivesPerSet)
|
||
|
formats := make([]*formatErasureV3, 32)
|
||
7 years ago
|
errs := make([]error, 32)
|
||
8 years ago
|
|
||
7 years ago
|
for i := 0; i < setCount; i++ {
|
||
5 years ago
|
for j := 0; j < drivesPerSet; j++ {
|
||
|
newFormat := format.Clone()
|
||
5 years ago
|
newFormat.Erasure.This = format.Erasure.Sets[i][j]
|
||
5 years ago
|
formats[i*drivesPerSet+j] = newFormat
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
quorumFormat, err := getFormatErasureInQuorum(formats)
|
||
8 years ago
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
7 years ago
|
// 16th disk is unformatted.
|
||
|
errs[15] = errUnformattedDisk
|
||
8 years ago
|
|
||
5 years ago
|
newFormats := newHealFormatSets(quorumFormat, setCount, drivesPerSet, formats, errs)
|
||
7 years ago
|
if newFormats == nil {
|
||
|
t.Fatal("Unexpected failure")
|
||
8 years ago
|
}
|
||
6 years ago
|
|
||
|
// Check if deployment IDs are preserved.
|
||
|
for i := range newFormats {
|
||
|
for j := range newFormats[i] {
|
||
|
if newFormats[i][j].ID != quorumFormat.ID {
|
||
|
t.Fatal("Deployment id in the new format is lost")
|
||
|
}
|
||
|
}
|
||
|
}
|
||
8 years ago
|
}
|
||
5 years ago
|
|
||
|
func BenchmarkInitStorageDisks256(b *testing.B) {
|
||
|
benchmarkInitStorageDisksN(b, 256)
|
||
|
}
|
||
|
|
||
|
func BenchmarkInitStorageDisks1024(b *testing.B) {
|
||
|
benchmarkInitStorageDisksN(b, 1024)
|
||
|
}
|
||
|
|
||
|
func BenchmarkInitStorageDisks2048(b *testing.B) {
|
||
|
benchmarkInitStorageDisksN(b, 2048)
|
||
|
}
|
||
|
|
||
|
func BenchmarkInitStorageDisksMax(b *testing.B) {
|
||
|
benchmarkInitStorageDisksN(b, 32*204)
|
||
|
}
|
||
|
|
||
|
func benchmarkInitStorageDisksN(b *testing.B, nDisks int) {
|
||
|
b.ResetTimer()
|
||
|
b.ReportAllocs()
|
||
|
|
||
|
fsDirs, err := getRandomDisks(nDisks)
|
||
|
if err != nil {
|
||
|
b.Fatal(err)
|
||
|
}
|
||
5 years ago
|
endpoints := mustGetNewEndpoints(fsDirs...)
|
||
5 years ago
|
b.RunParallel(func(pb *testing.PB) {
|
||
|
endpoints := endpoints
|
||
|
for pb.Next() {
|
||
|
initStorageDisksWithErrors(endpoints)
|
||
|
}
|
||
|
})
|
||
|
}
|