Skip to content

Commit 31db35d

Browse files
committed
Ensure correct IP is used to connect to ES
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent d7a8182 commit 31db35d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/testingutils/docker/elastic.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,20 @@ func SetupElastic() (*elastic.Client, func(), error) {
7979

8080
// Increase retry timeout (default is 1 minute)
8181
pool.MaxWait = 1 * time.Minute
82+
clientPort := resource.GetPort("9200/tcp")
83+
var esHost string
8284

8385
// Log network debugging info
8486
log.Infof("Container ID: %s", resource.Container.ID)
8587
log.Infof("Container IPAddress: %s", resource.Container.NetworkSettings.IPAddress)
8688
log.Infof("Container Gateway: %s", resource.Container.NetworkSettings.Gateway)
8789
log.Infof("Mapped port 9200/tcp: %s", resource.GetPort("9200/tcp"))
8890
for netName, netSettings := range resource.Container.NetworkSettings.Networks {
89-
log.Infof("Network %s: Gateway=%s, IPAddress=%s", netName, netSettings.Gateway, netSettings.IPAddress)
91+
esHost = netSettings.Gateway
92+
log.Infof("Setting ES host to gateway %s for network %s", esHost, netName)
93+
break
9094
}
9195

92-
clientPort := "9200"
93-
esHost := resource.Container.NetworkSettings.IPAddress
9496
esURL := fmt.Sprintf("http://%s:%s", esHost, clientPort)
9597
log.Infof("Will attempt to connect to Elasticsearch at: %s", esURL)
9698

0 commit comments

Comments
 (0)