Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix sidecar proxy test files with source and destination. #18620

Merged
merged 23 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f4239e2
mesh-controller: handle L4 protocols for a proxy without upstreams
ishustava Jul 23, 2023
ab6ce72
sidecar-controller: Support explicit destinations for L4 protocols an…
ishustava Jul 28, 2023
93631aa
endpoints-controller: add workload identity to the service endpoints …
ishustava Aug 3, 2023
f65f474
small fixes
ishustava Aug 4, 2023
7839d58
review comments
ishustava Aug 8, 2023
0b85a4b
Address PR comments
ishustava Aug 10, 2023
a281bdc
sidecar-proxy controller: Add support for transparent proxy
ishustava Aug 14, 2023
1d5f30a
PR review comments
ishustava Sep 7, 2023
4844da9
mesh-controller: handle L4 protocols for a proxy without upstreams
ishustava Jul 23, 2023
b1df340
sidecar-controller: Support explicit destinations for L4 protocols an…
ishustava Jul 28, 2023
cf81b48
endpoints-controller: add workload identity to the service endpoints …
ishustava Aug 3, 2023
7945918
small fixes
ishustava Aug 4, 2023
2a1f01b
review comments
ishustava Aug 8, 2023
2d486d8
Make sure endpoint refs route to mesh port instead of an app port
ishustava Aug 8, 2023
eae4bf6
Address PR comments
ishustava Aug 10, 2023
32928bc
fixing copyright
rboyer Aug 23, 2023
f95b1b0
tidy imports
rboyer Aug 23, 2023
3727bd4
sidecar-proxy controller: Add support for transparent proxy
ishustava Aug 14, 2023
28e00f6
tidy imports
rboyer Aug 23, 2023
df7b6cd
add copyright headers
rboyer Aug 23, 2023
22bbfca
Prefix sidecar proxy test files with source and destination.
hc-github-team-consul-core Aug 30, 2023
867f2a0
Merge branch 'main' into jm/prefix-tests
jmurret Sep 8, 2023
151d470
Update controller_test.go
jmurret Sep 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/scripts/filter_changed_files_go_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1


# Get the list of changed files
files_to_check=$(git diff --name-only origin/$GITHUB_BASE_REF)
Expand Down
3 changes: 2 additions & 1 deletion internal/catalog/catalogtest/test_integration_v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"github.com/hashicorp/consul/internal/catalog"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/endpoints"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/nodehealth"
Expand All @@ -19,7 +21,6 @@ import (
"github.com/hashicorp/consul/proto-public/pbresource"
"github.com/hashicorp/consul/proto/private/prototest"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/stretchr/testify/require"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
"context"
"sort"

"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

"github.com/hashicorp/consul/internal/catalog/internal/controllers/workloadhealth"
"github.com/hashicorp/consul/internal/catalog/internal/types"
"github.com/hashicorp/consul/internal/controller"
"github.com/hashicorp/consul/internal/resource"
pbcatalog "github.com/hashicorp/consul/proto-public/pbcatalog/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"context"
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

svctest "github.com/hashicorp/consul/agent/grpc-external/services/resource/testing"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/workloadhealth"
"github.com/hashicorp/consul/internal/catalog/internal/mappers/selectiontracker"
Expand All @@ -18,8 +21,6 @@ import (
"github.com/hashicorp/consul/proto/private/prototest"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/hashicorp/consul/sdk/testutil/retry"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

var (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package sidecarproxycache

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package sidecarproxycache

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package builder

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package builder

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package builder

import (
Expand Down Expand Up @@ -84,26 +87,29 @@ func TestBuildExplicitDestinations(t *testing.T) {
cases := map[string]struct {
destinations []*intermediate.Destination
}{
"l4-single-destination-ip-port-bind-address": {
"destination/l4-single-destination-ip-port-bind-address": {
destinations: []*intermediate.Destination{destinationIpPort},
},
"l4-single-destination-unix-socket-bind-address": {
"destination/l4-single-destination-unix-socket-bind-address": {
destinations: []*intermediate.Destination{destinationUnix},
},
"l4-multi-destination": {
"destination/l4-multi-destination": {
destinations: []*intermediate.Destination{destinationIpPort, destinationUnix},
},
}

for name, c := range cases {
proxyTmpl := New(testProxyStateTemplateID(), testIdentityRef(), "foo.consul", "dc1", nil).
BuildDestinations(c.destinations).
Build()
t.Run(name, func(t *testing.T) {

actual := protoToJSON(t, proxyTmpl)
expected := golden.Get(t, actual, name)
proxyTmpl := New(testProxyStateTemplateID(), testIdentityRef(), "foo.consul", "dc1", nil).
BuildDestinations(c.destinations).
Build()

require.JSONEq(t, expected, actual)
actual := protoToJSON(t, proxyTmpl)
expected := golden.Get(t, actual, name+".golden")

require.JSONEq(t, expected, actual)
})
}
}

Expand Down Expand Up @@ -177,13 +183,13 @@ func TestBuildImplicitDestinations(t *testing.T) {
cases := map[string]struct {
destinations []*intermediate.Destination
}{
"l4-single-implicit-destination-tproxy": {
"destination/l4-single-implicit-destination-tproxy": {
destinations: []*intermediate.Destination{destination1},
},
"l4-multiple-implicit-destinations-tproxy": {
"destination/l4-multiple-implicit-destinations-tproxy": {
destinations: []*intermediate.Destination{destination1, destination2},
},
"l4-implicit-and-explicit-destinations-tproxy": {
"destination/l4-implicit-and-explicit-destinations-tproxy": {
destinations: []*intermediate.Destination{destination2, destination3},
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package builder

import (
Expand All @@ -17,7 +20,7 @@ func TestBuildLocalApp(t *testing.T) {
cases := map[string]struct {
workload *pbcatalog.Workload
}{
"l4-single-workload-address-without-ports": {
"source/l4-single-workload-address-without-ports": {
workload: &pbcatalog.Workload{
Addresses: []*pbcatalog.WorkloadAddress{
{
Expand All @@ -30,7 +33,7 @@ func TestBuildLocalApp(t *testing.T) {
},
},
},
"l4-multiple-workload-addresses-without-ports": {
"source/l4-multiple-workload-addresses-without-ports": {
workload: &pbcatalog.Workload{
Addresses: []*pbcatalog.WorkloadAddress{
{
Expand All @@ -46,7 +49,7 @@ func TestBuildLocalApp(t *testing.T) {
},
},
},
"l4-multiple-workload-addresses-with-specific-ports": {
"source/l4-multiple-workload-addresses-with-specific-ports": {
workload: &pbcatalog.Workload{
Addresses: []*pbcatalog.WorkloadAddress{
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package builder

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
{
"proxyState": {
"clusters": {
"api-1.default.dc1.internal.foo.consul": {
"endpointGroup": {
"dynamic": {
"config": {
"disablePanicThreshold": true
},
"outboundTls": {
"outboundMesh": {
"identityKey": "test-identity",
"sni": "api-1.default.dc1.internal.foo.consul",
"validationContext": {
"spiffeIds": [
"spiffe://foo.consul/ap/default/ns/default/identity/api1-identity"
]
}
}
}
}
}
},
"api-2.default.dc1.internal.foo.consul": {
"endpointGroup": {
"dynamic": {
"config": {
"disablePanicThreshold": true
},
"outboundTls": {
"outboundMesh": {
"identityKey": "test-identity",
"sni": "api-2.default.dc1.internal.foo.consul",
"validationContext": {
"spiffeIds": [
"spiffe://foo.consul/ap/default/ns/default/identity/api2-identity"
]
}
}
}
}
}
}
},
"identity": {
"name": "test-identity",
"tenancy": {
"namespace": "default",
"partition": "default",
"peerName": "local"
}
},
"listeners": [
{
"capabilities": [
"CAPABILITY_TRANSPARENT"
],
"direction": "DIRECTION_OUTBOUND",
"hostPort": {
"host": "127.0.0.1",
"port": 15001
},
"name": "outbound_listener",
"routers": [
{
"l4": {
"name": "api-2.default.dc1.internal.foo.consul",
"statPrefix": "upstream.api-2.default.default.dc1"
},
"match": {
"prefixRanges": [
{
"addressPrefix": "2.2.2.2",
"prefixLen": 32
},
{
"addressPrefix": "3.3.3.3",
"prefixLen": 32
}
]
}
}
]
},
{
"capabilities": [
"CAPABILITY_TRANSPARENT"
],
"direction": "DIRECTION_OUTBOUND",
"hostPort": {
"host": "127.0.0.1",
"port": 15001
},
"name": "outbound_listener",
"routers": [
{
"l4": {
"name": "api-2.default.dc1.internal.foo.consul",
"statPrefix": "upstream.api-2.default.default.dc1"
},
"match": {
"prefixRanges": [
{
"addressPrefix": "2.2.2.2",
"prefixLen": 32
},
{
"addressPrefix": "3.3.3.3",
"prefixLen": 32
}
]
}
}
]
},
{
"capabilities": [
"CAPABILITY_TRANSPARENT"
],
"direction": "DIRECTION_OUTBOUND",
"hostPort": {
"host": "127.0.0.1",
"port": 15001
},
"name": "outbound_listener",
"routers": [
{
"l4": {
"name": "api-2.default.dc1.internal.foo.consul",
"statPrefix": "upstream.api-2.default.default.dc1"
},
"match": {
"prefixRanges": [
{
"addressPrefix": "2.2.2.2",
"prefixLen": 32
},
{
"addressPrefix": "3.3.3.3",
"prefixLen": 32
}
]
}
}
]
},
{
"direction": "DIRECTION_OUTBOUND",
"hostPort": {
"host": "1.1.1.1",
"port": 1234
},
"name": "api-1:tcp:1.1.1.1:1234",
"routers": [
{
"l4": {
"name": "api-1.default.dc1.internal.foo.consul",
"statPrefix": "upstream.api-1.default.default.dc1"
}
}
]
}
]
},
"requiredEndpoints": {
"api-1.default.dc1.internal.foo.consul": {
"id": {
"name": "api-1",
"tenancy": {
"namespace": "default",
"partition": "default",
"peerName": "local"
},
"type": {
"group": "catalog",
"groupVersion": "v1alpha1",
"kind": "ServiceEndpoints"
}
},
"port": "mesh"
},
"api-2.default.dc1.internal.foo.consul": {
"id": {
"name": "api-2",
"tenancy": {
"namespace": "default",
"partition": "default",
"peerName": "local"
},
"type": {
"group": "catalog",
"groupVersion": "v1alpha1",
"kind": "ServiceEndpoints"
}
},
"port": "mesh"
}
}
}
Loading