Skip to content

Commit

Permalink
Merge refs/heads/main into fix-eds-error
Browse files Browse the repository at this point in the history
  • Loading branch information
soloio-bulldozer[bot] authored Aug 9, 2024
2 parents 2719d6f + 3db9258 commit 2c4a9ae
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/v1.18.0-beta14/add-happy-path-routing-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: NON_USER_FACING
description: >-
Adds a happy path routing edge Gateway e2e test.
114 changes: 114 additions & 0 deletions test/kubernetes/e2e/features/basicrouting/edge_suite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package basicrouting

import (
"context"
"net/http"

"github.com/onsi/gomega"
"github.com/solo-io/gloo/pkg/utils/kubeutils"
"github.com/solo-io/gloo/pkg/utils/kubeutils/kubectl"
"github.com/solo-io/gloo/pkg/utils/requestutils/curl"
gatewaydefaults "github.com/solo-io/gloo/projects/gateway/pkg/defaults"
"github.com/solo-io/gloo/projects/gloo/pkg/defaults"
testmatchers "github.com/solo-io/gloo/test/gomega/matchers"
"github.com/solo-io/gloo/test/kubernetes/e2e"
testdefaults "github.com/solo-io/gloo/test/kubernetes/e2e/defaults"
ossvalidation "github.com/solo-io/gloo/test/kubernetes/e2e/features/validation"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/resources"
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
"github.com/stretchr/testify/suite"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var _ e2e.NewSuiteFunc = NewBasicEdgeRoutingSuite

// edgeBasicRoutingSuite is the Suite of happy path tests for the basic routing cases for edge gateway resources (VirtualService, Upstream, etc.)
type edgeBasicRoutingSuite struct {
suite.Suite

ctx context.Context

// testInstallation contains all the metadata/utilities necessary to execute a series of tests
// against an installation of Gloo Gateway
testInstallation *e2e.TestInstallation
}

func NewBasicEdgeRoutingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &edgeBasicRoutingSuite{
ctx: ctx,
testInstallation: testInst,
}
}

func (s *edgeBasicRoutingSuite) TestBasicVirtualServiceRouting() {
s.T().Cleanup(func() {
err := s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, testdefaults.NginxPodManifest)
s.Assertions.NoError(err, "can delete nginx pod")

err = s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, testdefaults.CurlPodManifest)
s.Assertions.NoError(err, "can delete curl pod")

err = s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, ossvalidation.ExampleVS, "-n", s.testInstallation.Metadata.InstallNamespace)
s.Assertions.NoError(err, "can delete virtual service")

err = s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, ossvalidation.ExampleUpstream, "-n", s.testInstallation.Metadata.InstallNamespace)
s.Assertions.NoError(err, "can delete upstream")
})

err := s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, testdefaults.NginxPodManifest)
s.Assert().NoError(err)
// Check that test resources are running
s.testInstallation.Assertions.EventuallyPodsRunning(s.ctx, testdefaults.NginxPod.ObjectMeta.GetNamespace(), metav1.ListOptions{
LabelSelector: "app.kubernetes.io/name=nginx",
})

err = s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, testdefaults.CurlPodManifest)
s.Assert().NoError(err)
// Check that test resources are running
s.testInstallation.Assertions.EventuallyPodsRunning(s.ctx, testdefaults.CurlPod.ObjectMeta.GetNamespace(), metav1.ListOptions{
LabelSelector: "app.kubernetes.io/name=curl",
})

// Upstream is only rejected when the upstream plugin is run when a valid cluster is present
err = s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, ossvalidation.ExampleUpstream, "-n", s.testInstallation.Metadata.InstallNamespace)
s.Assert().NoError(err, "can apply valid upstream")
s.testInstallation.Assertions.EventuallyResourceStatusMatchesState(
func() (resources.InputResource, error) {
return s.testInstallation.ResourceClients.UpstreamClient().Read(s.testInstallation.Metadata.InstallNamespace, ossvalidation.ExampleUpstreamName, clients.ReadOpts{Ctx: s.ctx})
},
core.Status_Accepted,
defaults.GlooReporter,
)
err = s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, ossvalidation.ExampleVS, "-n", s.testInstallation.Metadata.InstallNamespace)
s.Assert().NoError(err, "can apply valid virtual service")
s.testInstallation.Assertions.EventuallyResourceStatusMatchesState(
func() (resources.InputResource, error) {
return s.testInstallation.ResourceClients.VirtualServiceClient().Read(s.testInstallation.Metadata.InstallNamespace, ossvalidation.ExampleVsName, clients.ReadOpts{Ctx: s.ctx})
},
core.Status_Accepted,
defaults.GlooReporter,
)

// Should have a successful response
s.testInstallation.Assertions.AssertEventualCurlResponse(
s.ctx,
kubectl.PodExecOptions{
Name: testdefaults.CurlPod.Name,
Namespace: testdefaults.CurlPod.Namespace,
Container: "curl",
},
[]curl.Option{
curl.WithHost(kubeutils.ServiceFQDN(metav1.ObjectMeta{
Name: gatewaydefaults.GatewayProxyName,
Namespace: s.testInstallation.Metadata.InstallNamespace,
})),
curl.WithHostHeader("example.com"),
curl.WithPort(80),
},
&testmatchers.HttpResponse{
StatusCode: http.StatusOK,
Body: gomega.ContainSubstring(testdefaults.NginxResponse),
})

}
2 changes: 2 additions & 0 deletions test/kubernetes/e2e/tests/edge_gw_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tests
import (
"github.com/solo-io/gloo/test/kubernetes/e2e"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/admin_server"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/basicrouting"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/client_tls"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/headless_svc"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/port_routing"
Expand All @@ -19,6 +20,7 @@ func EdgeGwSuiteRunner() e2e.SuiteRunner {
edgeGwSuiteRunner.Register("ValidationAllowWarnings", validation_allow_warnings.NewTestingSuite)
edgeGwSuiteRunner.Register("GlooAdminServer", admin_server.NewTestingSuite)
edgeGwSuiteRunner.Register("ClientTls", client_tls.NewTestingSuite)
edgeGwSuiteRunner.Register("BasicRouting", basicrouting.NewBasicEdgeRoutingSuite)

return edgeGwSuiteRunner
}

0 comments on commit 2c4a9ae

Please sign in to comment.