Skip to content

Commit

Permalink
fix(e2e): port forward to service instead of pod of kuma-cp to improv…
Browse files Browse the repository at this point in the history
…e test stability (backport of #11737) (#11743)

* fix(e2e): port forward to service instead of pod of kuma-cp to improve test stability (#11737)

Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com>


---------

Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com>
Co-authored-by: Marcin Skalski <marcin.skalski@konghq.com>
Co-authored-by: Marcin Skalski <skalskimarcin33@gmail.com>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent b9b5d5d commit 6420c84
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/framework/k8s_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,15 @@ func (c *K8sControlPlane) GetKubectlOptions(namespace ...string) *k8s.KubectlOpt
}

func (c *K8sControlPlane) PortForwardKumaCP() {
kumaCpPods := c.GetKumaCPPods()
// There could be multiple pods still starting so pick one that's available already
for i := range kumaCpPods {
if k8s.IsPodAvailable(&kumaCpPods[i]) {
c.portFwd.apiServerTunnel = k8s.NewTunnel(c.GetKubectlOptions(Config.KumaNamespace), k8s.ResourceTypePod, kumaCpPods[i].Name, 0, 5681)
c.portFwd.apiServerTunnel.ForwardPort(c.t)
c.portFwd.ApiServerEndpoint = c.portFwd.apiServerTunnel.Endpoint()
return
}
kumaCpSvc := c.GetKumaCPSvc()
if k8s.IsServiceAvailable(&kumaCpSvc) {
c.portFwd.apiServerTunnel = k8s.NewTunnel(c.GetKubectlOptions(Config.KumaNamespace), k8s.ResourceTypeService, kumaCpSvc.Name, 0, 5681)
c.portFwd.apiServerTunnel.ForwardPort(c.t)
c.portFwd.ApiServerEndpoint = c.portFwd.apiServerTunnel.Endpoint()
return
}
c.t.Fatalf("Failed finding an available pod, allPods: %v", kumaCpPods)

c.t.Fatalf("Failed finding an available service, service: %v", kumaCpSvc)
}

func (c *K8sControlPlane) ClosePortForwards() {
Expand Down

0 comments on commit 6420c84

Please sign in to comment.