-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into npolshak/glooctl-tests
- Loading branch information
Showing
12 changed files
with
293 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
changelog: | ||
- type: NON_USER_FACING | ||
issueLink: https://github.com/solo-io/solo-projects/issues/6303 | ||
resolvesIssue: false | ||
description: >- | ||
Migrate gloomtls tests from kube2e to new framework. | ||
skipCI-docs-build:true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
test/kubernetes/e2e/features/gloomtls/gloomtls_edge_suite.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package gloomtls | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/onsi/gomega" | ||
"github.com/solo-io/gloo/projects/gateway/pkg/defaults" | ||
"github.com/solo-io/gloo/projects/gloo/cli/pkg/cmd/istio" | ||
"github.com/solo-io/gloo/test/gomega/matchers" | ||
testdefaults "github.com/solo-io/gloo/test/kubernetes/e2e/defaults" | ||
"github.com/stretchr/testify/suite" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/solo-io/gloo/pkg/utils/kubeutils" | ||
"github.com/solo-io/gloo/pkg/utils/requestutils/curl" | ||
"github.com/solo-io/gloo/test/kubernetes/e2e" | ||
) | ||
|
||
// gloomtlsEdgeGatewayTestingSuite is the entire Suite of tests for the "Gloo mtls" cases | ||
type gloomtlsEdgeGatewayTestingSuite 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 NewGloomtlsEdgeGatewayApiTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite { | ||
return &gloomtlsEdgeGatewayTestingSuite{ | ||
ctx: ctx, | ||
testInstallation: testInst, | ||
} | ||
} | ||
|
||
func (s *gloomtlsEdgeGatewayTestingSuite) SetupSuite() { | ||
err := s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, setupManifest) | ||
s.NoError(err, "can apply setup manifest") | ||
|
||
} | ||
|
||
func (s *gloomtlsEdgeGatewayTestingSuite) TearDownSuite() { | ||
err := s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, setupManifest) | ||
s.NoError(err, "can delete setup manifest") | ||
} | ||
|
||
func (s *gloomtlsEdgeGatewayTestingSuite) TestRouteSecureRequestToUpstream() { | ||
s.T().Cleanup(func() { | ||
err := s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, edgeRoutingResources, "-n", s.testInstallation.Metadata.InstallNamespace) | ||
s.NoError(err) | ||
}) | ||
|
||
err := s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, edgeRoutingResources, "-n", s.testInstallation.Metadata.InstallNamespace) | ||
s.NoError(err) | ||
|
||
// Check sds container is present | ||
listOpts := metav1.ListOptions{ | ||
LabelSelector: "gloo=gateway-proxy", | ||
} | ||
matcher := gomega.And( | ||
matchers.PodMatches(matchers.ExpectedPod{ContainerName: istio.SDSContainerName}), | ||
) | ||
|
||
s.testInstallation.Assertions.EventuallyPodsMatches(s.ctx, s.testInstallation.Metadata.InstallNamespace, listOpts, matcher, time.Minute*2) | ||
|
||
// Check curl works | ||
s.testInstallation.Assertions.AssertEventualCurlResponse( | ||
s.ctx, | ||
testdefaults.CurlPodExecOpt, | ||
[]curl.Option{ | ||
curl.WithHost(kubeutils.ServiceFQDN(metav1.ObjectMeta{Name: defaults.GatewayProxyName, Namespace: s.testInstallation.Metadata.InstallNamespace})), | ||
// The host header must match the domain in the VirtualService | ||
curl.WithHostHeader("example.com"), | ||
curl.WithPort(80), | ||
}, | ||
expectedHealthyResponse) | ||
} |
28 changes: 28 additions & 0 deletions
28
test/kubernetes/e2e/features/gloomtls/testdata/edge_resources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Don't set namespace, apply to test installation namespace | ||
apiVersion: gateway.solo.io/v1 | ||
kind: VirtualService | ||
metadata: | ||
name: example-vs | ||
spec: | ||
virtualHost: | ||
domains: | ||
- "example.com" | ||
routes: | ||
- matchers: | ||
- prefix: / | ||
routeAction: | ||
single: | ||
upstream: | ||
name: nginx-upstream | ||
--- | ||
apiVersion: gloo.solo.io/v1 | ||
kind: Upstream | ||
metadata: | ||
name: nginx-upstream | ||
spec: | ||
kube: | ||
selector: | ||
app.kubernetes.io/name: nginx | ||
serviceName: nginx-svc | ||
serviceNamespace: default | ||
servicePort: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
labels: | ||
app.kubernetes.io/name: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:stable | ||
ports: | ||
- containerPort: 80 | ||
name: http-web-svc | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx-svc | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: http-web-svc | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: curl | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: curl | ||
namespace: curl | ||
labels: | ||
app: curl | ||
version: v1 | ||
spec: | ||
containers: | ||
- name: curl | ||
image: curlimages/curl:7.83.1 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- "tail" | ||
- "-f" | ||
- "/dev/null" | ||
resources: | ||
requests: | ||
cpu: "100m" | ||
limits: | ||
cpu: "200m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package gloomtls | ||
|
||
import ( | ||
"net/http" | ||
"path/filepath" | ||
|
||
. "github.com/onsi/gomega" | ||
testmatchers "github.com/solo-io/gloo/test/gomega/matchers" | ||
"github.com/solo-io/skv2/codegen/util" | ||
) | ||
|
||
var ( | ||
expectedHealthyResponse = &testmatchers.HttpResponse{ | ||
StatusCode: http.StatusOK, | ||
Body: ContainSubstring("Welcome to nginx!"), | ||
} | ||
|
||
setupManifest = filepath.Join(util.MustGetThisDir(), "testdata", "setup.yaml") | ||
edgeRoutingResources = filepath.Join(util.MustGetThisDir(), "testdata", "edge_resources.yaml") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package tests_test | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/solo-io/gloo/test/kubernetes/e2e" | ||
. "github.com/solo-io/gloo/test/kubernetes/e2e/tests" | ||
"github.com/solo-io/gloo/test/kubernetes/testutils/gloogateway" | ||
"github.com/solo-io/gloo/test/kubernetes/testutils/helper" | ||
"github.com/solo-io/skv2/codegen/util" | ||
) | ||
|
||
// TestGloomtlsGatewayEdgeGateway is the function which executes a series of tests against a given installation where | ||
// the k8s Gateway controller is disabled and gloomtls is enabled | ||
func TestGloomtlsGatewayEdgeGateway(t *testing.T) { | ||
ctx := context.Background() | ||
testInstallation := e2e.CreateTestInstallation( | ||
t, | ||
&gloogateway.Context{ | ||
InstallNamespace: "gloo-gateway-edge-test", | ||
ValuesManifestFile: filepath.Join(util.MustGetThisDir(), "manifests", "gloomtls-edge-gateway-test-helm.yaml"), | ||
}, | ||
) | ||
|
||
testHelper := e2e.MustTestHelper(ctx, testInstallation) | ||
|
||
// We register the cleanup function _before_ we actually perform the installation. | ||
// This allows us to uninstall Gloo Gateway, in case the original installation only completed partially | ||
t.Cleanup(func() { | ||
if t.Failed() { | ||
testInstallation.PreFailHandler(ctx) | ||
} | ||
|
||
testInstallation.UninstallGlooGateway(ctx, func(ctx context.Context) error { | ||
return testHelper.UninstallGlooAll() | ||
}) | ||
}) | ||
|
||
// Install Gloo Gateway with only Gloo Edge Gateway APIs enabled | ||
testInstallation.InstallGlooGateway(ctx, func(ctx context.Context) error { | ||
return testHelper.InstallGloo(ctx, 5*time.Minute, helper.WithExtraArgs("--values", testInstallation.Metadata.ValuesManifestFile)) | ||
}) | ||
|
||
GloomtlsEdgeGwSuiteRunner().Run(ctx, t, testInstallation) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package tests | ||
|
||
import ( | ||
"github.com/solo-io/gloo/test/kubernetes/e2e" | ||
"github.com/solo-io/gloo/test/kubernetes/e2e/features/gloomtls" | ||
) | ||
|
||
func GloomtlsEdgeGwSuiteRunner() e2e.SuiteRunner { | ||
gloomtlsEdgeGwSuiteRunner := e2e.NewSuiteRunner(false) | ||
|
||
gloomtlsEdgeGwSuiteRunner.Register("Gloomtls", gloomtls.NewGloomtlsEdgeGatewayApiTestingSuite) | ||
|
||
return gloomtlsEdgeGwSuiteRunner | ||
} |
37 changes: 37 additions & 0 deletions
37
test/kubernetes/e2e/tests/manifests/gloomtls-edge-gateway-test-helm.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
global: | ||
glooMtls: | ||
enabled: true | ||
image: | ||
pullPolicy: IfNotPresent | ||
settings: | ||
create: true | ||
invalidConfigPolicy: | ||
replaceInvalidRoutes: true | ||
invalidRouteResponseCode: 404 | ||
invalidRouteResponseBody: Gloo Gateway has invalid configuration. | ||
gateway: | ||
enabled: true | ||
persistProxySpec: false | ||
logLevel: info | ||
validation: | ||
allowWarnings: true | ||
alwaysAcceptResources: false | ||
# skipping delete validation due to flakes per https://github.com/solo-io/solo-projects/issues/6272 | ||
webhook: | ||
skipDeleteValidationResources: | ||
- upstreams | ||
kubeGateway: | ||
# This is the field that enables the K8s Gateway Integration in Gloo Gateway | ||
enabled: false | ||
gloo: | ||
logLevel: info | ||
disableLeaderElection: true | ||
deployment: | ||
replicas: 1 | ||
livenessProbeEnabled: true | ||
gatewayProxies: | ||
gatewayProxy: | ||
healthyPanicThreshold: 0 | ||
# Disable discovery, not recommended for production. NOTE: Upstreams must be statically defined in the manfiests. | ||
discovery: | ||
enabled: false |