Skip to content

Commit

Permalink
List entities instead of dump.Get for getting config from gateways
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Jul 31, 2024
1 parent 8dd261c commit 89af240
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
1 change: 0 additions & 1 deletion test/e2e/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,5 @@ func ensureAllProxyReplicasAreConfigured(ctx context.Context, t *testing.T, env
t.Logf("proxy pod %s/%s: got the config", pod.Namespace, pod.Name)
}()
}

wg.Wait()
}
42 changes: 29 additions & 13 deletions test/e2e/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/blang/semver/v4"
"github.com/google/uuid"
"github.com/kong/go-database-reconciler/pkg/dump"
"github.com/kong/go-kong/kong"
"github.com/kong/kubernetes-testing-framework/pkg/clusters"
ktfkong "github.com/kong/kubernetes-testing-framework/pkg/clusters/addons/kong"
Expand Down Expand Up @@ -528,31 +527,48 @@ func verifyIngressWithEchoBackendsInAdminAPI(
t.Helper()

require.Eventually(t, func() bool {
d, err := dump.Get(ctx, kongClient, dump.Config{})
start := time.Now()
defer func() {
t.Logf("Try fetching config from %q started at %s, duration %v", kongClient.BaseRootURL(), start.Format(time.RFC3339), time.Since(start))
}()

services, err := kongClient.Services.ListAll(ctx)
if err != nil {
t.Logf("failed dumping config: %s", err)
t.Logf("failed to list services: %v", err)
return false
}
if len(d.Services) != 1 {
if len(services) != 1 || services[0].ID == nil {
t.Log("still no service found...")
return false
}
if len(d.Routes) != 1 {

routes, _, err := kongClient.Routes.ListForService(ctx, services[0].ID, &kong.ListOpt{Size: 10})
if err != nil {
t.Logf("failed to list routes for service %s: %v", *services[0].ID, err)
return false
}
if len(routes) != 1 {
t.Log("still no route found...")
return false
}
if d.Services[0].ID == nil ||
d.Routes[0].Service.ID == nil ||
*d.Services[0].ID != *d.Routes[0].Service.ID {
t.Log("still no matching service found...")

upstreams, err := kongClient.Upstreams.ListAll(ctx)
if err != nil {
t.Logf("failed to list upstreams: %v", err)
return false
}
if len(upstreams) != 1 || upstreams[0].ID == nil {
t.Logf("still no upstreams found...")
return false
}
if len(d.Targets) != noReplicas {
t.Log("still no target found...")

targets, err := kongClient.Targets.ListAll(ctx, upstreams[0].ID)
if err != nil {
t.Logf("failed to list targets for upstream %s: %v", *upstreams[0].ID, err)
return false
}
if len(d.Upstreams) != 1 {
t.Log("still no upstream found...")
if len(targets) != noReplicas {
t.Log("still no targets found...")
return false
}
return true
Expand Down

0 comments on commit 89af240

Please sign in to comment.