Skip to content

Commit

Permalink
Merge branch 'main' into yuval-k/defalt-test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuval-k authored Nov 27, 2024
2 parents e6b20e4 + 3bb702e commit 7edcc18
Show file tree
Hide file tree
Showing 13 changed files with 398 additions and 167 deletions.
6 changes: 6 additions & 0 deletions changelog/v1.18.0-rc3/disabling-flaky-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NON_USER_FACING
description: |
Disabling flaky test TestConfigureTCPRouteBackingDestinationsWithMultiServices
issueLink: https://github.com/solo-io/gloo/issues/10366
resolvesIssue: false
8 changes: 8 additions & 0 deletions changelog/v1.18.0-rc3/safe-ports-e2e.yaml
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/7307
resolvesIssue: false
description: >-
Ensure that tests which are dynamically selecting ports always skip port 9095.
Due to recent changes, when Gloo is running, this port will always be used.
We choose to skip this, as it is the easiest way to avoid issues.
8 changes: 8 additions & 0 deletions changelog/v1.18.0-rc3/vho-test-hardening.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
changelog:
- type: NON_USER_FACING
description: |
Strengthed VHO kubernetes/e2e tests. Addressed issue with checking for `content-length`
header in response containing `transfer-encoding: chunked` header.
Added to confirm previously conflicting VHO being accepted after blocker is deleted.
issueLink: https://github.com/k8sgateway/k8sgateway/issues/10310
resolvesIssue: false
25 changes: 24 additions & 1 deletion test/ginkgo/parallel/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,17 @@ func AdvancePort(p *uint32) uint32 {
// AdvancePortSafeListen returns a port that is safe to use in parallel tests
// It relies on pinging the port to see if it is in use
func AdvancePortSafeListen(p *uint32, retryOptions ...retry.Option) uint32 {
return MustAdvancePortSafe(p, portInUseListen, retryOptions...)
errIfPortInUse := func(proposedPort uint32) error {
if err := portInDenyList(proposedPort); err != nil {
return err
}
if err := portInUseListen(proposedPort); err != nil {
return err
}
return nil
}

return MustAdvancePortSafe(p, errIfPortInUse, retryOptions...)
}

func portInUseListen(proposedPort uint32) error {
Expand All @@ -88,3 +98,16 @@ func portInUseListen(proposedPort uint32) error {
// Port should available if the listener closes without an error
return ln.Close()
}

var denyListPorts = map[uint32]struct{}{
// See gloo/pkg/servers/admin/server.go
// See https://github.com/solo-io/solo-projects/issues/7307 for more details
9095: {},
}

func portInDenyList(proposedPort uint32) error {
if _, ok := denyListPorts[proposedPort]; ok {
return eris.Errorf("port %d is in deny list", proposedPort)
}
return nil
}
2 changes: 2 additions & 0 deletions test/kubernetes/e2e/features/services/tcproute/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (s *testingSuite) TestConfigureTCPRouteBackingDestinationsWithSingleService
}

func (s *testingSuite) TestConfigureTCPRouteBackingDestinationsWithMultiServices() {
s.T().Skip("skipping test until we resolve the reason it is flaky")

s.T().Cleanup(func() {
err := s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, multiTcpRouteManifest)
s.NoError(err, "can delete manifest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ spec:
namespaces:
from: Same
---
apiVersion: gateway.solo.io/v1
kind: RouteOption
metadata:
name: header-manipulation
spec:
options:
headerManipulation:
responseHeadersToAdd:
- header:
key: "x-bar"
value: "bar"
append: false
- header:
key: "x-baz"
value: "baz"
append: false
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
Expand All @@ -28,7 +45,13 @@ spec:
hostnames:
- "example.com"
rules:
- backendRefs:
- filters:
- type: ExtensionRef
extensionRef:
group: gateway.solo.io
kind: RouteOption
name: header-manipulation
backendRefs:
- name: example-svc
port: 8080
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: gateway.solo.io/v1
kind: VirtualHostOption
metadata:
name: extra-vho-merge
name: remove-x-baz-merge
spec:
targetRefs:
- group: gateway.networking.k8s.io
Expand All @@ -10,5 +10,5 @@ spec:
options:
headerManipulation:
responseHeadersToRemove:
- "content-type"
- "x-baz"
includeAttemptCountInResponse: true
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: gateway.solo.io/v1
kind: VirtualHostOption
metadata:
name: remove-content-type
name: remove-x-bar-header
spec:
targetRefs:
- group: gateway.networking.k8s.io
Expand All @@ -10,4 +10,4 @@ spec:
options:
headerManipulation:
responseHeadersToRemove:
- "content-type"
- "x-bar"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: gateway.solo.io/v1
kind: VirtualHostOption
metadata:
name: remove-content-length
name: remove-x-baz-header
spec:
targetRefs:
- group: gateway.networking.k8s.io
Expand All @@ -10,4 +10,4 @@ spec:
options:
headerManipulation:
responseHeadersToRemove:
- "content-length"
- "x-baz"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: gateway.solo.io/v1
kind: VirtualHostOption
metadata:
name: add-foo-header
name: add-x-foo-header
spec:
targetRefs:
- group: gateway.networking.k8s.io
Expand All @@ -12,5 +12,5 @@ spec:
headerManipulation:
responseHeadersToAdd:
- header:
key: foo
value: bar
key: x-foo
value: foo
82 changes: 52 additions & 30 deletions test/kubernetes/e2e/features/virtualhost_options/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ var (
filepath.Join(util.MustGetThisDir(), "testdata", "setup.yaml"),
e2edefaults.CurlPodManifest,
}
basicVhOManifest = filepath.Join(util.MustGetThisDir(), "testdata", "basic-vho.yaml")
sectionNameVhOManifest = filepath.Join(util.MustGetThisDir(), "testdata", "section-name-vho.yaml")
extraVhOManifest = filepath.Join(util.MustGetThisDir(), "testdata", "extra-vho.yaml")
badVhOManifest = filepath.Join(util.MustGetThisDir(), "testdata", "webhook-reject-bad-vho.yaml")
extraVhOMergeManifest = filepath.Join(util.MustGetThisDir(), "testdata", "extra-vho-merge.yaml")

manifestVhoRemoveXBar = filepath.Join(util.MustGetThisDir(), "testdata", "vho-remove-x-bar.yaml")
manifestVhoSectionAddXFoo = filepath.Join(util.MustGetThisDir(), "testdata", "vho-section-add-x-foo.yaml")
manifestVhoRemoveXBaz = filepath.Join(util.MustGetThisDir(), "testdata", "vho-remove-x-baz.yaml")
manifestVhoWebhookReject = filepath.Join(util.MustGetThisDir(), "testdata", "vho-webhook-reject.yaml")
manifestVhoMergeRemoveXBaz = filepath.Join(util.MustGetThisDir(), "testdata", "vho-merge-remove-x-baz.yaml")

// When we apply the setup file, we expect resources to be created with this metadata
glooProxyObjectMeta = metav1.ObjectMeta{
Expand All @@ -50,51 +51,72 @@ var (
},
}

// VirtualHostOption resource to be created
basicVirtualHostOptionMeta = metav1.ObjectMeta{
Name: "remove-content-length",
// VHO to add a x-foo header
vhoRemoveXBar = metav1.ObjectMeta{
Name: "remove-x-bar-header",
Namespace: "default",
}
// Extra VirtualHostOption resource to be created
extraVirtualHostOptionMeta = metav1.ObjectMeta{
Name: "remove-content-type",
// VHO to remove a x-baz header
vhoRemoveXBaz = metav1.ObjectMeta{
Name: "remove-x-baz-header",
Namespace: "default",
}
// Extra VirtualHostOption resource to be created to test merging of options
extraMergeVirtualHostOptionMeta = metav1.ObjectMeta{
Name: "extra-vho-merge",
// VHO to remove a x-baz header
vhoMergeRemoveXBaz = metav1.ObjectMeta{
Name: "remove-x-baz-merge",
Namespace: "default",
}
// SectionName VirtualHostOption resource to be created
sectionNameVirtualHostOptionMeta = metav1.ObjectMeta{
Name: "add-foo-header",
// VHO to add a x-foo header in a section
vhoSectionAddXFoo = metav1.ObjectMeta{
Name: "add-x-foo-header",
Namespace: "default",
}
// Bad VirtualHostOption resource to be created
badVirtualHostOptionMeta = metav1.ObjectMeta{
// VHO that should be rejected by the validating webhook
vhoWebhookReject = metav1.ObjectMeta{
Name: "bad-retries",
Namespace: "default",
}

expectedResponseWithoutContentLength = &matchers.HttpResponse{
// Expects a 200 response with x-bar and x-baz headers
defaultResponse = &matchers.HttpResponse{
StatusCode: http.StatusOK,
Custom: gomega.And(
gomega.Not(matchers.ContainHeaderKeys([]string{"x-foo"})),
matchers.ContainHeaderKeys([]string{"x-bar", "x-baz"}),
),
Body: gstruct.Ignore(),
}

// Expects default response with no x-bar header
expectedResponseWithoutXBar = &matchers.HttpResponse{
StatusCode: http.StatusOK,
Custom: gomega.Not(matchers.ContainHeaderKeys([]string{"content-length"})),
Body: gstruct.Ignore(),
Custom: gomega.And(
gomega.Not(matchers.ContainHeaderKeys([]string{"x-bar"})),
matchers.ContainHeaderKeys([]string{"x-baz"}),
),
Body: gstruct.Ignore(),
}

expectedResponseWithoutContentType = &matchers.HttpResponse{
// Expects default response with no x-baz header
expectedResponseWithoutXBaz = &matchers.HttpResponse{
StatusCode: http.StatusOK,
Custom: gomega.Not(matchers.ContainHeaderKeys([]string{"content-type"})),
Body: gstruct.Ignore(),
Custom: gomega.And(
matchers.ContainHeaderKeys([]string{"x-bar"}),
gomega.Not(matchers.ContainHeaderKeys([]string{"x-baz"})),
),
Body: gstruct.Ignore(),
}

expectedResponseWithFooHeader = &matchers.HttpResponse{
// Expects default response with x-foo header
expectedResponseWithXFoo = &matchers.HttpResponse{
StatusCode: http.StatusOK,
Headers: map[string]interface{}{
"foo": gomega.Equal("bar"),
"x-foo": gomega.Equal("foo"),
},
// Make sure the content-length isn't being removed as a function of the unwanted VHO
Custom: matchers.ContainHeaderKeys([]string{"content-length"}),
Body: gstruct.Ignore(),
// Make sure the x-bar isn't being removed as a function of the unwanted VHO
Custom: gomega.And(
matchers.ContainHeaderKeys([]string{"x-foo", "x-bar", "x-baz"}),
),
Body: gstruct.Ignore(),
}
)
Loading

0 comments on commit 7edcc18

Please sign in to comment.