mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
distributed-XL: Support to run one minio process per export even on the same machine. (#2999)
fixes #2983
This commit is contained in:
committed by
Harshavardhana
parent
41f9ab1c69
commit
32c3a558e9
@@ -18,7 +18,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -64,23 +63,47 @@ func TestFinalizeEndpoints(t *testing.T) {
|
||||
|
||||
// Tests all the expected input disks for function checkSufficientDisks.
|
||||
func TestCheckSufficientDisks(t *testing.T) {
|
||||
xlDisks := []string{
|
||||
"/mnt/backend1",
|
||||
"/mnt/backend2",
|
||||
"/mnt/backend3",
|
||||
"/mnt/backend4",
|
||||
"/mnt/backend5",
|
||||
"/mnt/backend6",
|
||||
"/mnt/backend7",
|
||||
"/mnt/backend8",
|
||||
"/mnt/backend9",
|
||||
"/mnt/backend10",
|
||||
"/mnt/backend11",
|
||||
"/mnt/backend12",
|
||||
"/mnt/backend13",
|
||||
"/mnt/backend14",
|
||||
"/mnt/backend15",
|
||||
"/mnt/backend16",
|
||||
var xlDisks []string
|
||||
if runtime.GOOS == "windows" {
|
||||
xlDisks = []string{
|
||||
"C:\\mnt\\backend1",
|
||||
"C:\\mnt\\backend2",
|
||||
"C:\\mnt\\backend3",
|
||||
"C:\\mnt\\backend4",
|
||||
"C:\\mnt\\backend5",
|
||||
"C:\\mnt\\backend6",
|
||||
"C:\\mnt\\backend7",
|
||||
"C:\\mnt\\backend8",
|
||||
"C:\\mnt\\backend9",
|
||||
"C:\\mnt\\backend10",
|
||||
"C:\\mnt\\backend11",
|
||||
"C:\\mnt\\backend12",
|
||||
"C:\\mnt\\backend13",
|
||||
"C:\\mnt\\backend14",
|
||||
"C:\\mnt\\backend15",
|
||||
"C:\\mnt\\backend16",
|
||||
"C:\\mnt\\backend17",
|
||||
}
|
||||
} else {
|
||||
xlDisks = []string{
|
||||
"/mnt/backend1",
|
||||
"/mnt/backend2",
|
||||
"/mnt/backend3",
|
||||
"/mnt/backend4",
|
||||
"/mnt/backend5",
|
||||
"/mnt/backend6",
|
||||
"/mnt/backend7",
|
||||
"/mnt/backend8",
|
||||
"/mnt/backend9",
|
||||
"/mnt/backend10",
|
||||
"/mnt/backend11",
|
||||
"/mnt/backend12",
|
||||
"/mnt/backend13",
|
||||
"/mnt/backend14",
|
||||
"/mnt/backend15",
|
||||
"/mnt/backend16",
|
||||
"/mnt/backend17",
|
||||
}
|
||||
}
|
||||
// List of test cases fo sufficient disk verification.
|
||||
testCases := []struct {
|
||||
@@ -104,7 +127,7 @@ func TestCheckSufficientDisks(t *testing.T) {
|
||||
},
|
||||
// Larger than maximum number of disks > 16.
|
||||
{
|
||||
append(xlDisks[0:16], "/mnt/unsupported"),
|
||||
xlDisks,
|
||||
errXLMaxDisks,
|
||||
},
|
||||
// Lesser than minimum number of disks < 6.
|
||||
@@ -121,47 +144,16 @@ func TestCheckSufficientDisks(t *testing.T) {
|
||||
|
||||
// Validates different variations of input disks.
|
||||
for i, testCase := range testCases {
|
||||
if checkSufficientDisks(testCase.disks) != testCase.expectedErr {
|
||||
endpoints, err := parseStorageEndPoints(testCase.disks, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %s", err)
|
||||
}
|
||||
if checkSufficientDisks(endpoints) != testCase.expectedErr {
|
||||
t.Errorf("Test %d expected to pass for disks %s", i+1, testCase.disks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckNamingDisks(t *testing.T) {
|
||||
var testCases []struct {
|
||||
disks []string
|
||||
err error
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
testCases = []struct {
|
||||
disks []string
|
||||
err error
|
||||
}{
|
||||
{[]string{`:C:\\a\\b\\c`}, &net.AddrError{Err: "Missing address in network path", Addr: `:C:\\a\\b\\c`}},
|
||||
{[]string{`localhost:C:\\mnt\\disk1`, `localhost:C:\\mnt\\disk2`}, nil},
|
||||
}
|
||||
} else {
|
||||
testCases = []struct {
|
||||
disks []string
|
||||
err error
|
||||
}{
|
||||
{[]string{"localhost:/mnt/disk1", ":/a/b/c"}, &net.AddrError{Err: "Missing address in network path", Addr: ":/a/b/c"}},
|
||||
{[]string{"localhost:/mnt/disk1", "localhost:/mnt/disk2"}, nil},
|
||||
}
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
err := checkNamingDisks(test.disks)
|
||||
if test.err != nil {
|
||||
if err == nil || err.Error() != test.err.Error() {
|
||||
t.Errorf("Test %d failed with %v but expected error %v", i+1, err, test.err)
|
||||
}
|
||||
} else if err != test.err {
|
||||
t.Errorf("Test %d failed with %v but expected error %v", i+1, err, test.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckServerSyntax(t *testing.T) {
|
||||
app := cli.NewApp()
|
||||
app.Commands = []cli.Command{serverCmd}
|
||||
@@ -186,7 +178,11 @@ func TestCheckServerSyntax(t *testing.T) {
|
||||
t.Errorf("Test %d failed to parse arguments %s", i+1, disks)
|
||||
}
|
||||
defer removeRoots(disks)
|
||||
_ = validateDisks(disks, nil)
|
||||
endpoints, err := parseStorageEndPoints(disks, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %s", err)
|
||||
}
|
||||
_ = validateDisks(endpoints, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +264,11 @@ func TestIsDistributedSetup(t *testing.T) {
|
||||
|
||||
}
|
||||
for i, test := range testCases {
|
||||
res := isDistributedSetup(test.disks)
|
||||
endpoints, err := parseStorageEndPoints(test.disks, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %s", err)
|
||||
}
|
||||
res := isDistributedSetup(endpoints)
|
||||
if res != test.result {
|
||||
t.Errorf("Test %d: expected result %t but received %t", i+1, test.result, res)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user