mirror of
https://github.com/minio/minio.git
synced 2025-11-21 18:26:04 -05:00
Handle localhost distributed setups properly (#8577)
Fixes an issue reported by @klauspost and @vadmeste This PR also allows users to expand their clusters from single node XL deployment to distributed mode.
This commit is contained in:
@@ -137,7 +137,7 @@ func TestHostUnmarshalJSON(t *testing.T) {
|
||||
{[]byte(`"12play"`), &Host{"12play", 0, false}, false},
|
||||
{[]byte(`"play-minio-io"`), &Host{"play-minio-io", 0, false}, false},
|
||||
{[]byte(`"play--min.io"`), &Host{"play--min.io", 0, false}, false},
|
||||
{[]byte(`":9000"`), nil, true},
|
||||
{[]byte(`":9000"`), &Host{"", 9000, true}, false},
|
||||
{[]byte(`"[fe80::8097:76eb:b397:e067%wlp2s0]"`), &Host{"fe80::8097:76eb:b397:e067%wlp2s0", 0, false}, false},
|
||||
{[]byte(`"[fe80::8097:76eb:b397:e067]:9000"`), &Host{"fe80::8097:76eb:b397:e067", 9000, true}, false},
|
||||
{[]byte(`"fe80::8097:76eb:b397:e067%wlp2s0"`), nil, true},
|
||||
@@ -154,20 +154,23 @@ func TestHostUnmarshalJSON(t *testing.T) {
|
||||
{[]byte(`":"`), nil, true},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
var host Host
|
||||
err := host.UnmarshalJSON(testCase.data)
|
||||
expectErr := (err != nil)
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run("", func(t *testing.T) {
|
||||
var host Host
|
||||
err := host.UnmarshalJSON(testCase.data)
|
||||
expectErr := (err != nil)
|
||||
|
||||
if expectErr != testCase.expectErr {
|
||||
t.Fatalf("test %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr)
|
||||
}
|
||||
|
||||
if !testCase.expectErr {
|
||||
if !reflect.DeepEqual(&host, testCase.expectedHost) {
|
||||
t.Fatalf("test %v: host: expected: %#v, got: %#v", i+1, testCase.expectedHost, host)
|
||||
if expectErr != testCase.expectErr {
|
||||
t.Errorf("error: expected: %v, got: %v", testCase.expectErr, expectErr)
|
||||
}
|
||||
}
|
||||
|
||||
if !testCase.expectErr {
|
||||
if !reflect.DeepEqual(&host, testCase.expectedHost) {
|
||||
t.Errorf("host: expected: %#v, got: %#v", testCase.expectedHost, host)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +191,7 @@ func TestParseHost(t *testing.T) {
|
||||
{"12play", &Host{"12play", 0, false}, false},
|
||||
{"play-minio-io", &Host{"play-minio-io", 0, false}, false},
|
||||
{"play--min.io", &Host{"play--min.io", 0, false}, false},
|
||||
{":9000", nil, true},
|
||||
{":9000", &Host{"", 9000, true}, false},
|
||||
{"play:", nil, true},
|
||||
{"play::", nil, true},
|
||||
{"play:90000", nil, true},
|
||||
@@ -199,19 +202,22 @@ func TestParseHost(t *testing.T) {
|
||||
{"", nil, true},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
host, err := ParseHost(testCase.s)
|
||||
expectErr := (err != nil)
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run("", func(t *testing.T) {
|
||||
host, err := ParseHost(testCase.s)
|
||||
expectErr := (err != nil)
|
||||
|
||||
if expectErr != testCase.expectErr {
|
||||
t.Fatalf("test %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr)
|
||||
}
|
||||
|
||||
if !testCase.expectErr {
|
||||
if !reflect.DeepEqual(host, testCase.expectedHost) {
|
||||
t.Fatalf("test %v: host: expected: %#v, got: %#v", i+1, testCase.expectedHost, host)
|
||||
if expectErr != testCase.expectErr {
|
||||
t.Errorf("error: expected: %v, got: %v", testCase.expectErr, expectErr)
|
||||
}
|
||||
}
|
||||
|
||||
if !testCase.expectErr {
|
||||
if !reflect.DeepEqual(host, testCase.expectedHost) {
|
||||
t.Errorf("host: expected: %#v, got: %#v", testCase.expectedHost, host)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user