@@ -85,7 +85,7 @@ func TestClientWithoutURL(t *testing.T) {
85
85
}
86
86
87
87
func TestClientWithSingleURL (t * testing.T ) {
88
- client , err := NewClient (SetURL ("http://localhost :9200" ))
88
+ client , err := NewClient (SetURL ("http://127.0.0.1 :9200" ))
89
89
if err != nil {
90
90
t .Fatal (err )
91
91
}
@@ -103,11 +103,11 @@ func TestClientWithSingleURL(t *testing.T) {
103
103
}
104
104
105
105
func TestClientWithMultipleURLs (t * testing.T ) {
106
- client , err := NewClient (SetURL ("http://localhost :9200" , "http://localhost :9201" ))
106
+ client , err := NewClient (SetURL ("http://127.0.0.1 :9200" , "http://127.0.0.1 :9201" ))
107
107
if err != nil {
108
108
t .Fatal (err )
109
109
}
110
- // The client should sniff both URLs, but only localhost :9200 should return nodes.
110
+ // The client should sniff both URLs, but only 127.0.0.1 :9200 should return nodes.
111
111
if len (client .conns ) != 1 {
112
112
t .Fatalf ("expected exactly 1 node in the local cluster, got: %d (%v)" , len (client .conns ), client .conns )
113
113
}
@@ -135,25 +135,25 @@ func TestClientWithBasicAuth(t *testing.T) {
135
135
}
136
136
137
137
func TestClientSniffSuccess (t * testing.T ) {
138
- client , err := NewClient (SetURL ("http://localhost :19200" , "http://localhost :9200" ))
138
+ client , err := NewClient (SetURL ("http://127.0.0.1 :19200" , "http://127.0.0.1 :9200" ))
139
139
if err != nil {
140
140
t .Fatal (err )
141
141
}
142
- // The client should sniff both URLs, but only localhost :9200 should return nodes.
142
+ // The client should sniff both URLs, but only 127.0.0.1 :9200 should return nodes.
143
143
if len (client .conns ) != 1 {
144
144
t .Fatalf ("expected exactly 1 node in the local cluster, got: %d (%v)" , len (client .conns ), client .conns )
145
145
}
146
146
}
147
147
148
148
func TestClientSniffFailure (t * testing.T ) {
149
- _ , err := NewClient (SetURL ("http://localhost :19200" , "http://localhost :19201" ))
149
+ _ , err := NewClient (SetURL ("http://127.0.0.1 :19200" , "http://127.0.0.1 :19201" ))
150
150
if err == nil {
151
151
t .Fatalf ("expected cluster to fail with no nodes found" )
152
152
}
153
153
}
154
154
155
155
func TestClientSniffDisabled (t * testing.T ) {
156
- client , err := NewClient (SetSniff (false ), SetURL ("http://localhost :9200" , "http://localhost :9201" ))
156
+ client , err := NewClient (SetSniff (false ), SetURL ("http://127.0.0.1 :9200" , "http://127.0.0.1 :9201" ))
157
157
if err != nil {
158
158
t .Fatal (err )
159
159
}
@@ -168,17 +168,17 @@ func TestClientSniffDisabled(t *testing.T) {
168
168
t .Fatal (err )
169
169
}
170
170
}
171
- // The first connection (localhost :9200) should now be okay.
172
- if i , found := findConn ("http://localhost :9200" , client .conns ... ); ! found {
173
- t .Fatalf ("expected connection to %q to be found" , "http://localhost :9200" )
171
+ // The first connection (127.0.0.1 :9200) should now be okay.
172
+ if i , found := findConn ("http://127.0.0.1 :9200" , client .conns ... ); ! found {
173
+ t .Fatalf ("expected connection to %q to be found" , "http://127.0.0.1 :9200" )
174
174
} else {
175
175
if conn := client .conns [i ]; conn .IsDead () {
176
176
t .Fatal ("expected connection to be alive, but it is dead" )
177
177
}
178
178
}
179
- // The second connection (localhost :9201) should now be marked as dead.
180
- if i , found := findConn ("http://localhost :9201" , client .conns ... ); ! found {
181
- t .Fatalf ("expected connection to %q to be found" , "http://localhost :9201" )
179
+ // The second connection (127.0.0.1 :9201) should now be marked as dead.
180
+ if i , found := findConn ("http://127.0.0.1 :9201" , client .conns ... ); ! found {
181
+ t .Fatalf ("expected connection to %q to be found" , "http://127.0.0.1 :9201" )
182
182
} else {
183
183
if conn := client .conns [i ]; ! conn .IsDead () {
184
184
t .Fatal ("expected connection to be dead, but it is alive" )
0 commit comments