|
| 1 | +package gloo_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "os/exec" |
| 5 | + |
| 6 | + "github.com/google/uuid" |
| 7 | + . "github.com/onsi/ginkgo/v2" |
| 8 | + . "github.com/onsi/gomega" |
| 9 | + gatewayv1 "github.com/solo-io/gloo/projects/gateway/pkg/api/v1" |
| 10 | + gloov1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1" |
| 11 | + "github.com/solo-io/gloo/projects/gloo/pkg/api/v1/gloosnapshot" |
| 12 | + "github.com/solo-io/gloo/test/helpers" |
| 13 | + "github.com/solo-io/gloo/test/kube2e" |
| 14 | + "github.com/solo-io/solo-kit/pkg/api/v1/resources/core" |
| 15 | + |
| 16 | + "github.com/solo-io/solo-kit/pkg/api/v1/clients" |
| 17 | +) |
| 18 | + |
| 19 | +const ( |
| 20 | + testServerName = "testserver" |
| 21 | + testServerPort = 1234 |
| 22 | +) |
| 23 | + |
| 24 | +var _ = Describe("EDS", func() { |
| 25 | + var ( |
| 26 | + testServerDestination *gloov1.Destination |
| 27 | + testServerVs *gatewayv1.VirtualService |
| 28 | + |
| 29 | + glooResources *gloosnapshot.ApiSnapshot |
| 30 | + ) |
| 31 | + |
| 32 | + BeforeEach(func() { |
| 33 | + // Create a VirtualService routing directly to the testServer kubernetes service |
| 34 | + testServerDestination = &gloov1.Destination{ |
| 35 | + DestinationType: &gloov1.Destination_Kube{ |
| 36 | + Kube: &gloov1.KubernetesServiceDestination{ |
| 37 | + Ref: &core.ResourceRef{ |
| 38 | + Namespace: testHelper.InstallNamespace, |
| 39 | + Name: testServerName, |
| 40 | + }, |
| 41 | + Port: uint32(testServerPort), |
| 42 | + }, |
| 43 | + }, |
| 44 | + } |
| 45 | + testServerVs = helpers.NewVirtualServiceBuilder(). |
| 46 | + WithName(testServerName). |
| 47 | + WithNamespace(testHelper.InstallNamespace). |
| 48 | + WithLabel(kube2e.UniqueTestResourceLabel, uuid.New().String()). |
| 49 | + WithDomain(testServerName). |
| 50 | + WithRoutePrefixMatcher(testServerName, "/"). |
| 51 | + WithRouteActionToSingleDestination(testServerName, testServerDestination). |
| 52 | + Build() |
| 53 | + |
| 54 | + // The set of resources that these tests will generate |
| 55 | + glooResources = &gloosnapshot.ApiSnapshot{ |
| 56 | + VirtualServices: gatewayv1.VirtualServiceList{ |
| 57 | + // many tests route to the TestServer Service so it makes sense to just |
| 58 | + // always create it |
| 59 | + // the other benefit is this ensures that all tests start with a valid Proxy CR |
| 60 | + testServerVs, |
| 61 | + }, |
| 62 | + } |
| 63 | + }) |
| 64 | + |
| 65 | + JustBeforeEach(func() { |
| 66 | + err := snapshotWriter.WriteSnapshot(glooResources, clients.WriteOpts{ |
| 67 | + Ctx: ctx, |
| 68 | + OverwriteExisting: false, |
| 69 | + }) |
| 70 | + Expect(err).NotTo(HaveOccurred()) |
| 71 | + }) |
| 72 | + |
| 73 | + JustAfterEach(func() { |
| 74 | + err := snapshotWriter.DeleteSnapshot(glooResources, clients.DeleteOpts{ |
| 75 | + Ctx: ctx, |
| 76 | + IgnoreNotExist: true, |
| 77 | + }) |
| 78 | + Expect(err).NotTo(HaveOccurred()) |
| 79 | + }) |
| 80 | + |
| 81 | + Context("Rest EDS", Ordered, func() { |
| 82 | + BeforeAll(func() { |
| 83 | + // enable REST EDS |
| 84 | + kube2e.UpdateRestEdsSetting(ctx, true, testHelper.InstallNamespace) |
| 85 | + }) |
| 86 | + |
| 87 | + AfterAll(func() { |
| 88 | + // reset REST EDS to default |
| 89 | + kube2e.UpdateRestEdsSetting(ctx, false, testHelper.InstallNamespace) |
| 90 | + }) |
| 91 | + |
| 92 | + // This test is inspired by the issue here: https://github.com/solo-io/gloo/issues/8968 |
| 93 | + // There were some versions of Gloo Edge 1.15.x which depended on versions of envoy-gloo |
| 94 | + // which did not have REST config subscription enabled, and so gateway-proxy logs would |
| 95 | + // contain warnings about not finding a registered config subscription factory implementation |
| 96 | + // for REST EDS. This test validates that we have not regressed to that state. |
| 97 | + It("should not warn when REST EDS is configured", func() { |
| 98 | + Consistently(func(g Gomega) { |
| 99 | + // Get envoy logs from gateway-proxy deployment |
| 100 | + logsCmd := exec.Command("kubectl", "logs", "-n", testHelper.InstallNamespace, |
| 101 | + "deployment/gateway-proxy") |
| 102 | + logsOut, err := logsCmd.Output() |
| 103 | + g.Expect(err).NotTo(HaveOccurred()) |
| 104 | + |
| 105 | + // ensure that the logs do not contain any presence of the text: |
| 106 | + // Didn't find a registered config subscription factory implementation for name: 'envoy.config_subscription.rest' |
| 107 | + g.Expect(string(logsOut)).NotTo(ContainSubstring("Didn't find a registered config subscription factory implementation for name: 'envoy.config_subscription.rest'")) |
| 108 | + }, "10s", "1s").Should(Succeed()) |
| 109 | + }) |
| 110 | + }) |
| 111 | +}) |
0 commit comments