server: Startup sequence should be more idempotent. (#2974)

Fixes #2971 - honors ignore-disks option properly.
Fixes #2969 - change the net.Dial to have a timeout of 3secs.
This commit is contained in:
Harshavardhana
2016-10-17 14:31:33 -07:00
committed by GitHub
parent 686a610fc3
commit f8e13fb00e
6 changed files with 88 additions and 11 deletions

View File

@@ -19,7 +19,10 @@ package cmd
import (
"os"
"path/filepath"
"reflect"
"testing"
"github.com/minio/minio/pkg/disk"
)
// TestStorageInfo - tests storage info.
@@ -73,6 +76,51 @@ func TestStorageInfo(t *testing.T) {
}
}
// Sort valid disks info.
func TestSortingValidDisks(t *testing.T) {
testCases := []struct {
disksInfo []disk.Info
validDisksInfo []disk.Info
}{
// One of the disks is offline.
{
disksInfo: []disk.Info{
{Total: 150, Free: 10},
{Total: 0, Free: 0},
{Total: 200, Free: 10},
{Total: 100, Free: 10},
},
validDisksInfo: []disk.Info{
{Total: 100, Free: 10},
{Total: 150, Free: 10},
{Total: 200, Free: 10},
},
},
// All disks are online.
{
disksInfo: []disk.Info{
{Total: 150, Free: 10},
{Total: 200, Free: 10},
{Total: 100, Free: 10},
{Total: 115, Free: 10},
},
validDisksInfo: []disk.Info{
{Total: 100, Free: 10},
{Total: 115, Free: 10},
{Total: 150, Free: 10},
{Total: 200, Free: 10},
},
},
}
for i, testCase := range testCases {
validDisksInfo := sortValidDisksInfo(testCase.disksInfo)
if !reflect.DeepEqual(validDisksInfo, testCase.validDisksInfo) {
t.Errorf("Test %d: Expected %#v, Got %#v", i+1, testCase.validDisksInfo, validDisksInfo)
}
}
}
// TestNewXL - tests initialization of all input disks
// and constructs a valid `XL` object
func TestNewXL(t *testing.T) {