Describe the bug
If you are using different DOCKER_HOST than localhost, kafka gnomock doesn't work.
To Reproduce
Expected behavior
Everything works
System (please complete the following information):
Additional context
The whole issue is caused by ADV_HOST being hard-coded to 127.0.0.1 in the preset.
The solution was, for me, write this at the start of the test:
dockerIP := ""
if dh := os.Getenv("DOCKER_HOST"); dh != "" {
u, err := url.Parse(dh)
if err == nil {
if host := u.Hostname(); host != "" {
ips, err := net.LookupIP(host)
if err != nil {
t.Fatalf("Could not get IPs: %v\n", err)
}
dockerIP = ips[0].String()
}
}
}
And later:
opts := []gnomock.Option{
gnomock.WithDebugMode(), gnomock.WithLogWriter(os.Stdout),
gnomock.WithContainerName("kafka"),
}
if dockerIP != "" {
opts = append(opts, gnomock.WithEnv("ADV_HOST="+dockerIP))
}
container, err := gnomock.Start(
p,
opts...,
)
This should be either set automatically (I am not sure why is the localhost IP hardcoded, as gnomock does know that I am using DOCKER_HOST) or, at least, documented
Describe the bug
If you are using different DOCKER_HOST than localhost, kafka gnomock doesn't work.
To Reproduce
Expected behavior
Everything works
System (please complete the following information):
Additional context
The whole issue is caused by ADV_HOST being hard-coded to 127.0.0.1 in the preset.
The solution was, for me, write this at the start of the test:
And later:
This should be either set automatically (I am not sure why is the localhost IP hardcoded, as gnomock does know that I am using DOCKER_HOST) or, at least, documented