Skip to content

Commit

Permalink
tests(e2e) fix tests if using ipv6 locally (#3022)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont authored Oct 28, 2021
1 parent f07e2d4 commit db4f9b0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/framework/universal_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func NewUniversalApp(t testing.TestingT, clusterName, dpName string, mode AppMod
// Here we make sure the IPv6 address is not allocated to the container unless explicitly requested.
opts.OtherOptions = append(opts.OtherOptions, "--sysctl", "net.ipv6.conf.all.disable_ipv6=1")
}
opts.OtherOptions = append(opts.OtherOptions, app.publishPortsForDocker()...)
opts.OtherOptions = append(opts.OtherOptions, app.publishPortsForDocker(isipv6)...)
container, err := docker.RunAndGetIDE(t, GetUniversalImage(), &opts)
if err != nil {
return nil, err
Expand Down Expand Up @@ -262,9 +262,16 @@ func (s *UniversalApp) allocatePublicPortsFor(ports ...string) {
}
}

func (s *UniversalApp) publishPortsForDocker() (args []string) {
func (s *UniversalApp) publishPortsForDocker(isipv6 bool) (args []string) {
// If we aren't using IPv6 in the container then we only want to listen on
// IPv4 interfaces to prevent resolving 'localhost' to the IPv6 address of
// the container and having the container not respond.
ip := "0.0.0.0:"
if isipv6 {
ip = ""
}
for port, pubPort := range s.ports {
args = append(args, "--publish="+pubPort+":"+port)
args = append(args, "--publish="+ip+pubPort+":"+port)
}
return
}
Expand Down

0 comments on commit db4f9b0

Please sign in to comment.