fix e2e lb test on aws: call hostname instead of ip (#838)

Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
Fabian Kammel 2022-12-29 12:09:40 +01:00 committed by GitHub
parent 3daa0af9d3
commit 1caa40147a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,7 @@ func TestLoadBalancer(t *testing.T) {
// Wait for external IP to be registered
svc := testEventuallyExternalIPAvailable(t, k)
loadBalancerIP := svc.Status.LoadBalancer.Ingress[0].IP
loadBalancerIP := getIPOrHostname(t, svc)
loadBalancerPort := svc.Spec.Ports[0].Port
require.Equal(initialPort, loadBalancerPort)
url := buildURL(t, loadBalancerIP, loadBalancerPort)
@ -76,6 +76,14 @@ func TestLoadBalancer(t *testing.T) {
assert.True(hasNUniqueStrings(allHostnames, numPods))
}
func getIPOrHostname(t *testing.T, svc *coreV1.Service) string {
t.Helper()
if ip := svc.Status.LoadBalancer.Ingress[0].IP; ip != "" {
return ip
}
return svc.Status.LoadBalancer.Ingress[0].Hostname
}
func hasNUniqueStrings(elements []string, n int) bool {
m := make(map[string]bool)
for i := range elements {