include ip address while doing checkPortAvailability (#7818)

While checking for port availability, ip address should be included.
When a machine has multiple ip addresses, multiple minio instances
or some other applications can be run on same port but different
ip address.

Fixes #7685
This commit is contained in:
Kanagaraj M
2019-06-25 03:32:40 +05:30
committed by kannappanr
parent 61229b38f7
commit 48cb271a46
4 changed files with 10 additions and 8 deletions

View File

@@ -206,11 +206,13 @@ func TestCheckPortAvailability(t *testing.T) {
defer listener.Close()
testCases := []struct {
host string
port string
expectedErr error
}{
{port, fmt.Errorf("listen tcp :%v: bind: address already in use", port)},
{getFreePort(), nil},
{"", port, fmt.Errorf("listen tcp :%v: bind: address already in use", port)},
{"127.0.0.1", port, fmt.Errorf("listen tcp 127.0.0.1:%v: bind: address already in use", port)},
{"", getFreePort(), nil},
}
for _, testCase := range testCases {
@@ -219,7 +221,7 @@ func TestCheckPortAvailability(t *testing.T) {
continue
}
err := checkPortAvailability(testCase.port)
err := checkPortAvailability(testCase.host, testCase.port)
if testCase.expectedErr == nil {
if err != nil {
t.Fatalf("error: expected = <nil>, got = %v", err)