Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system-test: wait for LoadBalancer to receive IP address #223

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions tests/system-tests/rdscore/internal/rdscorecommon/egress-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,6 @@ func VerifyEgressServiceWithClusterETP(ctx SpecContext) {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Created EgressService %q in %q namespace",
egrSVCBuilder.Object.Name, egrSVCBuilder.Object.Namespace)

By("Getting status of service")

refreshSVC := svcBuilder.Exists()

Expect(refreshSVC).To(BeTrue(), fmt.Sprintf("Error refressing service %q", svcBuilder.Definition.Name))

By("Finding pod from app deployment")

clientPods := findPodWithSelector(RDSCoreConfig.EgressServiceNS, egressSVC1Labels)
Expand All @@ -353,12 +347,35 @@ func VerifyEgressServiceWithClusterETP(ctx SpecContext) {
fmt.Sprintf("Application pods matching %q label not found in %q namespace",
RDSCoreConfig.EgressServiceNS, egressSVC1Labels))

By("Getting status of service")

Eventually(func() bool {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Check service %q in %q namespace has LoadBalancer IP",
svcBuilder.Definition.Name, svcBuilder.Definition.Namespace)

refreshSVC := svcBuilder.Exists()

if !refreshSVC {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Failed to refresh service status")

return false
}

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Service has %d IP addresses",
len(svcBuilder.Object.Status.LoadBalancer.Ingress))

return len(svcBuilder.Object.Status.LoadBalancer.Ingress) != 0
}).WithContext(ctx).WithPolling(15*time.Second).WithTimeout(3*time.Minute).Should(BeTrue(),
"Service does not have LoadBalancer IP address")

loadBalancerIP := svcBuilder.Object.Status.LoadBalancer.Ingress[0].IP

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("LoadBalancer IP address: %q", loadBalancerIP)

cmdToRun := []string{"/bin/bash", "-c",
fmt.Sprintf("curl --connect-timeout 3 -Ls http://%s:%s/clientip",
RDSCoreConfig.EgressServiceRemoteIP, RDSCoreConfig.EgressServiceRemotePort)}

loadBalancerIP := svcBuilder.Object.Status.LoadBalancer.Ingress[0].IP

verifyPodSourceAddress(clientPods, cmdToRun, loadBalancerIP)
}

Expand Down Expand Up @@ -483,9 +500,24 @@ func VerifyEgressServiceWithLocalETP(ctx SpecContext) {

By("Getting status of service")

refreshSVC := svcBuilder.Exists()
Eventually(func() bool {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Check service %q in %q namespace has LoadBalancer IP",
svcBuilder.Definition.Name, svcBuilder.Definition.Namespace)

refreshSVC := svcBuilder.Exists()

if !refreshSVC {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Failed to refresh service status")

Expect(refreshSVC).To(BeTrue(), fmt.Sprintf("Error refressing service %q", svcBuilder.Definition.Name))
return false
}

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Service has %d IP addresses",
len(svcBuilder.Object.Status.LoadBalancer.Ingress))

return len(svcBuilder.Object.Status.LoadBalancer.Ingress) != 0
}).WithContext(ctx).WithPolling(15*time.Second).WithTimeout(3*time.Minute).Should(BeTrue(),
"Service does not have LoadBalancer IP address")

By("Finding pod from app deployment")

Expand All @@ -501,6 +533,8 @@ func VerifyEgressServiceWithLocalETP(ctx SpecContext) {

loadBalancerIP := svcBuilder.Object.Status.LoadBalancer.Ingress[0].IP

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("LoadBalancer IP address: %q", loadBalancerIP)

verifyPodSourceAddress(clientPods, cmdToRun, loadBalancerIP)

By(fmt.Sprintf("Accessing workload via LoadBalancer's IP %s", loadBalancerIP))
Expand Down
Loading