mirror of
https://github.com/minio/minio.git
synced 2025-11-10 22:10:12 -05:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user