Skip to content

Commit

Permalink
Update test dialer to use ip when available
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-su committed Apr 18, 2024
1 parent 5f9768c commit bbb2121
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/conformance/ingress/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,20 @@ func CreateDialContext(ctx context.Context, t *testing.T, ing *v1alpha1.Ingress,
t.Fatal("Ingress does not have a public load balancer assigned.")
}

if ing.Status.PublicLoadBalancer.Ingress[0].IP != "" {
dial := network.NewBackoffDialer(dialBackoff)
ingressIP := ing.Status.PublicLoadBalancer.Ingress[0].IP

port := 80
if ing.Spec.Rules[0].Visibility == v1alpha1.IngressVisibilityExternalIP && ing.Spec.HTTPOption == v1alpha1.HTTPOptionRedirected {
port = 443
}

return func(ctx context.Context, _ string, _ string) (net.Conn, error) {
return dial(ctx, "tcp", fmt.Sprintf("%s:%d", ingressIP, port))
}
}

// TODO(mattmoor): I'm open to tricks that would let us cleanly test multiple
// public load balancers or LBs with multiple ingresses (below), but want to
// keep our simple tests simple, thus the [0]s...
Expand Down

0 comments on commit bbb2121

Please sign in to comment.