2023-03-28 19:12:30 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2018-10-03 19:37:53 +00:00
|
|
|
package envoy
|
|
|
|
|
|
|
|
import (
|
2019-04-29 16:27:57 +00:00
|
|
|
"encoding/json"
|
2018-10-09 09:57:26 +00:00
|
|
|
"flag"
|
2022-12-20 17:58:19 +00:00
|
|
|
"fmt"
|
2019-07-30 13:56:56 +00:00
|
|
|
"net"
|
2019-04-29 16:27:57 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
2018-10-09 09:57:26 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2022-12-20 17:58:19 +00:00
|
|
|
"strconv"
|
2018-10-03 19:37:53 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
2020-04-14 14:48:02 +00:00
|
|
|
|
2021-04-07 19:22:52 +00:00
|
|
|
"github.com/mitchellh/cli"
|
2023-01-09 20:16:00 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-04-07 19:22:52 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2023-01-16 17:31:56 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2020-04-14 14:48:02 +00:00
|
|
|
"github.com/hashicorp/consul/agent"
|
|
|
|
"github.com/hashicorp/consul/agent/xds"
|
|
|
|
"github.com/hashicorp/consul/api"
|
2023-03-06 15:32:06 +00:00
|
|
|
"github.com/hashicorp/consul/envoyextensions/xdscommon"
|
2020-04-14 14:48:02 +00:00
|
|
|
"github.com/hashicorp/consul/sdk/testutil"
|
2018-10-03 19:37:53 +00:00
|
|
|
)
|
|
|
|
|
2018-10-09 09:57:26 +00:00
|
|
|
var update = flag.Bool("update", false, "update golden files")
|
|
|
|
|
2019-07-30 13:56:56 +00:00
|
|
|
func TestEnvoyCommand_noTabs(t *testing.T) {
|
2018-10-03 19:37:53 +00:00
|
|
|
t.Parallel()
|
|
|
|
if strings.ContainsRune(New(nil).Help(), '\t') {
|
|
|
|
t.Fatal("help has tabs")
|
|
|
|
}
|
|
|
|
}
|
2018-10-09 09:57:26 +00:00
|
|
|
|
2020-03-26 16:20:56 +00:00
|
|
|
func TestEnvoyGateway_Validation(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
cases := []struct {
|
|
|
|
name string
|
|
|
|
args []string
|
|
|
|
output string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"-register for non-gateway",
|
2020-05-13 17:56:53 +00:00
|
|
|
[]string{"-register", "-proxy-id", "not-a-gateway"},
|
2020-03-26 16:20:56 +00:00
|
|
|
"Auto-Registration can only be used for gateways",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"-mesh-gateway and -gateway cannot be combined",
|
|
|
|
[]string{"-register", "-mesh-gateway", "-gateway", "mesh"},
|
|
|
|
"The mesh-gateway flag is deprecated and cannot be used alongside the gateway flag",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"no proxy registration specified nor discovered",
|
|
|
|
[]string{""},
|
|
|
|
"No proxy ID specified",
|
|
|
|
},
|
2022-06-06 16:23:08 +00:00
|
|
|
{
|
|
|
|
"-register with nodename",
|
|
|
|
[]string{"-register", "-proxy-id", "gw-svc-id", "-node-name", "gw-node"},
|
|
|
|
"'-register' cannot be used with '-node-name'",
|
|
|
|
},
|
2020-03-26 16:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
c.init()
|
|
|
|
|
|
|
|
code := c.Run(tc.args)
|
|
|
|
if code == 0 {
|
|
|
|
t.Errorf("%s: expected non-zero exit", tc.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
output := ui.ErrorWriter.String()
|
|
|
|
if !strings.Contains(output, tc.output) {
|
|
|
|
t.Errorf("expected %q to contain %q", output, tc.output)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-09 09:57:26 +00:00
|
|
|
// testSetAndResetEnv sets the env vars passed as KEY=value strings in the
|
|
|
|
// current ENV and returns a func() that will undo it's work at the end of the
|
|
|
|
// test for use with defer.
|
|
|
|
func testSetAndResetEnv(t *testing.T, env []string) func() {
|
|
|
|
old := make(map[string]*string)
|
|
|
|
for _, e := range env {
|
|
|
|
pair := strings.SplitN(e, "=", 2)
|
|
|
|
current := os.Getenv(pair[0])
|
|
|
|
if current != "" {
|
|
|
|
old[pair[0]] = ¤t
|
|
|
|
} else {
|
|
|
|
// save it as a nil so we know to remove again
|
|
|
|
old[pair[0]] = nil
|
|
|
|
}
|
2021-09-15 23:22:22 +00:00
|
|
|
require.NoError(t, os.Setenv(pair[0], pair[1]))
|
2018-10-09 09:57:26 +00:00
|
|
|
}
|
|
|
|
// Return a func that will reset to old values
|
|
|
|
return func() {
|
|
|
|
for k, v := range old {
|
|
|
|
if v == nil {
|
|
|
|
os.Unsetenv(k)
|
|
|
|
} else {
|
|
|
|
os.Setenv(k, *v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
type generateConfigTestCase struct {
|
|
|
|
Name string
|
2021-09-15 23:22:22 +00:00
|
|
|
TLSServer bool
|
2023-01-16 17:31:56 +00:00
|
|
|
ACLEnabled bool
|
2020-11-16 23:37:19 +00:00
|
|
|
Flags []string
|
|
|
|
Env []string
|
|
|
|
Files map[string]string
|
|
|
|
ProxyConfig map[string]interface{}
|
2023-01-09 20:16:00 +00:00
|
|
|
ProxyDefaults api.ProxyConfigEntry
|
2020-11-16 23:37:19 +00:00
|
|
|
NamespacesEnabled bool
|
2023-01-06 18:34:49 +00:00
|
|
|
XDSPorts agent.GRPCPorts // used to mock an agent's configured gRPC ports. Plaintext defaults to 8502 and TLS defaults to 8503.
|
|
|
|
AgentSelf110 bool // fake the agent API from versions v1.10 and earlier
|
2023-03-06 15:32:06 +00:00
|
|
|
GRPCDisabled bool
|
2020-11-16 23:37:19 +00:00
|
|
|
WantArgs BootstrapTplArgs
|
|
|
|
WantErr string
|
2023-01-16 17:31:56 +00:00
|
|
|
WantWarn string
|
2020-11-16 23:37:19 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 09:57:26 +00:00
|
|
|
// This tests the args we use to generate the template directly because they
|
|
|
|
// encapsulate all the argument and default handling code which is where most of
|
|
|
|
// the logic is. We also allow generating golden files but only for cases that
|
|
|
|
// pass the test of having their template args generated as expected.
|
|
|
|
func TestGenerateConfig(t *testing.T) {
|
2020-11-16 23:37:19 +00:00
|
|
|
cases := []generateConfigTestCase{
|
2018-10-09 09:57:26 +00:00
|
|
|
{
|
|
|
|
Name: "no-args",
|
|
|
|
Flags: []string{},
|
|
|
|
Env: []string{},
|
|
|
|
WantErr: "No proxy ID specified",
|
|
|
|
},
|
2022-06-06 16:23:08 +00:00
|
|
|
{
|
|
|
|
Name: "node-name without proxy-id",
|
|
|
|
Flags: []string{"-node-name", "test-node"},
|
|
|
|
WantErr: "'-node-name' requires '-proxy-id'",
|
|
|
|
},
|
2022-12-19 19:37:27 +00:00
|
|
|
{
|
2023-03-06 15:32:06 +00:00
|
|
|
Name: "gRPC disabled",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
GRPCDisabled: true,
|
|
|
|
WantErr: "agent has grpc disabled",
|
2022-12-19 19:37:27 +00:00
|
|
|
},
|
2018-10-09 09:57:26 +00:00
|
|
|
{
|
|
|
|
Name: "defaults",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
2019-04-29 16:27:57 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2018-10-09 09:57:26 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2022-06-06 16:23:08 +00:00
|
|
|
{
|
|
|
|
Name: "defaults-nodemeta",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-node-name", "test-node"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
NodeName: "test-node",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2023-03-10 20:52:54 +00:00
|
|
|
{
|
2023-05-16 18:36:05 +00:00
|
|
|
Name: "telemetry-collector",
|
2023-03-10 20:52:54 +00:00
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
2023-05-16 18:36:05 +00:00
|
|
|
"envoy_telemetry_collector_bind_socket_dir": "/tmp/consul/telemetry-collector",
|
2023-03-10 20:52:54 +00:00
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2021-03-04 22:15:47 +00:00
|
|
|
{
|
|
|
|
Name: "prometheus-metrics",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-prometheus-backend-port", "20100", "-prometheus-scrape-path", "/scrape-path"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// When envoy_prometheus_bind_addr is set, if
|
|
|
|
// PrometheusBackendPort is set, there will be a
|
|
|
|
// "prometheus_backend" cluster in the Envoy configuration.
|
|
|
|
"envoy_prometheus_bind_addr": "0.0.0.0:9000",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "20100",
|
|
|
|
PrometheusScrapePath: "/scrape-path",
|
2018-10-09 09:57:26 +00:00
|
|
|
},
|
|
|
|
},
|
2022-06-17 00:18:37 +00:00
|
|
|
{
|
|
|
|
Name: "prometheus-metrics-tls-ca-file",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-prometheus-backend-port", "20100", "-prometheus-scrape-path", "/scrape-path",
|
|
|
|
"-prometheus-ca-file", "../../../test/key/ourdomain.cer", "-prometheus-cert-file", "../../../test/key/ourdomain_server.cer",
|
|
|
|
"-prometheus-key-file", "../../../test/key/ourdomain_server.key"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// When envoy_prometheus_bind_addr is set, if
|
|
|
|
// PrometheusBackendPort is set, there will be a
|
|
|
|
// "prometheus_backend" cluster in the Envoy configuration.
|
|
|
|
"envoy_prometheus_bind_addr": "0.0.0.0:9000",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "20100",
|
|
|
|
PrometheusScrapePath: "/scrape-path",
|
|
|
|
PrometheusCAFile: "../../../test/key/ourdomain.cer",
|
|
|
|
PrometheusCertFile: "../../../test/key/ourdomain_server.cer",
|
|
|
|
PrometheusKeyFile: "../../../test/key/ourdomain_server.key",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "prometheus-metrics-tls-ca-path",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-prometheus-backend-port", "20100", "-prometheus-scrape-path", "/scrape-path",
|
|
|
|
"-prometheus-ca-path", "../../../test/ca_path", "-prometheus-cert-file", "../../../test/key/ourdomain_server.cer",
|
|
|
|
"-prometheus-key-file", "../../../test/key/ourdomain_server.key"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// When envoy_prometheus_bind_addr is set, if
|
|
|
|
// PrometheusBackendPort is set, there will be a
|
|
|
|
// "prometheus_backend" cluster in the Envoy configuration.
|
|
|
|
"envoy_prometheus_bind_addr": "0.0.0.0:9000",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "20100",
|
|
|
|
PrometheusScrapePath: "/scrape-path",
|
|
|
|
PrometheusCAPath: "../../../test/ca_path",
|
|
|
|
PrometheusCertFile: "../../../test/key/ourdomain_server.cer",
|
|
|
|
PrometheusKeyFile: "../../../test/key/ourdomain_server.key",
|
|
|
|
},
|
|
|
|
},
|
2019-04-30 14:59:00 +00:00
|
|
|
{
|
|
|
|
Name: "token-arg",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-token", "c9a52720-bf6c-4aa6-b8bc-66881a5ade95"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-30 14:59:00 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
Token: "c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-30 14:59:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "token-env",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
Env: []string{
|
|
|
|
"CONSUL_HTTP_TOKEN=c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-30 14:59:00 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
Token: "c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-30 14:59:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "token-file-arg",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-token-file", "@@TEMPDIR@@token.txt",
|
|
|
|
},
|
|
|
|
Files: map[string]string{
|
|
|
|
"token.txt": "c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-30 14:59:00 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
Token: "c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-30 14:59:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "token-file-env",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
Env: []string{
|
|
|
|
"CONSUL_HTTP_TOKEN_FILE=@@TEMPDIR@@token.txt",
|
|
|
|
},
|
|
|
|
Files: map[string]string{
|
|
|
|
"token.txt": "c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-30 14:59:00 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
Token: "c9a52720-bf6c-4aa6-b8bc-66881a5ade95",
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-30 14:59:00 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-09 09:57:26 +00:00
|
|
|
{
|
|
|
|
Name: "grpc-addr-flag",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-grpc-addr", "localhost:9999"},
|
2019-04-29 16:27:57 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
2018-10-09 09:57:26 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2018-10-09 09:57:26 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "9999",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2018-10-09 09:57:26 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2018-10-09 09:57:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "grpc-addr-env",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
Env: []string{
|
|
|
|
"CONSUL_GRPC_ADDR=localhost:9999",
|
|
|
|
},
|
2019-04-29 16:27:57 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
2018-10-09 09:57:26 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2018-10-09 09:57:26 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "9999",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-06-07 09:26:43 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-05 15:06:47 +00:00
|
|
|
{
|
|
|
|
Name: "grpc-addr-unix",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-grpc-addr", "unix:///var/run/consul.sock"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentSocket: "/var/run/consul.sock",
|
|
|
|
},
|
2019-07-05 15:06:47 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-07-05 15:06:47 +00:00
|
|
|
},
|
|
|
|
},
|
2023-01-06 18:34:49 +00:00
|
|
|
{
|
|
|
|
Name: "grpc-addr-unix-with-tls",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-grpc-ca-file", "../../../test/ca/root.cer",
|
|
|
|
"-grpc-addr", "unix:///var/run/consul.sock"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentSocket: "/var/run/consul.sock",
|
|
|
|
AgentTLS: true,
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
AgentCAPEM: `-----BEGIN CER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NVBAYT\nAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEcMBoGA1UE\nChMTSGFzaGlDb3JwIFRlc3QgQ2VydDEMMAoGA1UECxMDRGV2MRYwFAYDVQQDEw10\nZXN0LmludGVybmFsMSAwHgYJKoZIhvcNAQkBFhF0ZXN0QGludGVybmFsLmNvbYIJ\nAIewRMI8OnvTMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADa9fV9h\ngjapBlkNmu64WX0Ufub5dsJrdHS8672P30S7ILB7Mk0W8sL65IezRsZnG898yHf9\n2uzmz5OvNTM9K380g7xFlyobSVq+6yqmmSAlA/ptAcIIZT727P5jig/DB7fzJM3g\njctDlEGOmEe50GQXc25VKpcpjAsNQi5ER5gowQ0v3IXNZs+yU+LvxLHc0rUJ/XSp\nlFCAMOqd5uRoMOejnT51G6krvLNzPaQ3N9jQfNVY4Q0zfs0M+6dRWvqfqB9Vyq8/\nPOLMld+HyAZEBk9zK3ZVIXx6XS4dkDnSNR91njLq7eouf6M7+7s/oMQZZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----\n`,
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2019-08-01 16:53:34 +00:00
|
|
|
{
|
2022-09-01 17:32:11 +00:00
|
|
|
Name: "xds-addr-config",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
XDSPorts: agent.GRPCPorts{Plaintext: 9999, TLS: 0},
|
2021-07-09 19:17:29 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "9999",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2022-09-01 17:32:11 +00:00
|
|
|
{
|
|
|
|
Name: "grpc-tls-addr-config",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
XDSPorts: agent.GRPCPorts{Plaintext: 9997, TLS: 9998},
|
|
|
|
AgentSelf110: false,
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "9998",
|
|
|
|
AgentTLS: true,
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2021-07-09 19:17:29 +00:00
|
|
|
{
|
|
|
|
Name: "deprecated-grpc-addr-config",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
2022-09-01 17:32:11 +00:00
|
|
|
XDSPorts: agent.GRPCPorts{Plaintext: 9999, TLS: 0},
|
2021-07-09 19:17:29 +00:00
|
|
|
AgentSelf110: true,
|
2019-08-01 16:53:34 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2019-08-01 16:53:34 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "9999",
|
|
|
|
},
|
2019-08-01 16:53:34 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-08-01 16:53:34 +00:00
|
|
|
},
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
{
|
2023-01-16 17:31:56 +00:00
|
|
|
Name: "access-log-path",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-admin-access-log-path", "/some/path/access.log"},
|
|
|
|
WantWarn: "-admin-access-log-path is deprecated",
|
2019-06-07 09:26:43 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2019-06-07 09:26:43 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/some/path/access.log",
|
2018-10-09 09:57:26 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2018-10-09 09:57:26 +00:00
|
|
|
},
|
|
|
|
},
|
2019-12-13 16:44:48 +00:00
|
|
|
{
|
2022-12-19 19:37:27 +00:00
|
|
|
Name: "missing-ca-file",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-ca-file", "some/path"},
|
2019-12-13 16:44:48 +00:00
|
|
|
WantErr: "Error loading CA File: open some/path: no such file or directory",
|
|
|
|
},
|
|
|
|
{
|
2021-09-15 23:22:22 +00:00
|
|
|
Name: "existing-ca-file",
|
|
|
|
TLSServer: true,
|
2022-11-18 20:36:20 +00:00
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-grpc-ca-file", "../../../test/ca/root.cer"},
|
|
|
|
Env: []string{"CONSUL_GRPC_ADDR=https://127.0.0.1:8502"},
|
2019-12-13 16:44:48 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2019-12-13 16:44:48 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
AgentTLS: true,
|
|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xTCBwoAUo/nrOfqvbee2VklVKIFlyQEbuJWhgZ6kgZswgZgxCzAJBgNVBAYT\nAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEcMBoGA1UE\nChMTSGFzaGlDb3JwIFRlc3QgQ2VydDEMMAoGA1UECxMDRGV2MRYwFAYDVQQDEw10\nZXN0LmludGVybmFsMSAwHgYJKoZIhvcNAQkBFhF0ZXN0QGludGVybmFsLmNvbYIJ\nAIewRMI8OnvTMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADa9fV9h\ngjapBlkNmu64WX0Ufub5dsJrdHS8672P30S7ILB7Mk0W8sL65IezRsZnG898yHf9\n2uzmz5OvNTM9K380g7xFlyobSVq+6yqmmSAlA/ptAcIIZT727P5jig/DB7fzJM3g\njctDlEGOmEe50GQXc25VKpcpjAsNQi5ER5gowQ0v3IXNZs+yU+LvxLHc0rUJ/XSp\nlFCAMOqd5uRoMOejnT51G6krvLNzPaQ3N9jQfNVY4Q0zfs0M+6dRWvqfqB9Vyq8/\nPOLMld+HyAZEBk9zK3ZVIXx6XS4dkDnSNR91njLq7eouf6M7+7s/oMQZZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----\n`,
|
2020-09-08 10:16:16 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-09-08 10:16:16 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-12-19 19:37:27 +00:00
|
|
|
Name: "missing-ca-path",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-ca-path", "some/path"},
|
2020-09-08 10:16:16 +00:00
|
|
|
WantErr: "lstat some/path: no such file or directory",
|
|
|
|
},
|
|
|
|
{
|
2021-09-15 23:22:22 +00:00
|
|
|
Name: "existing-ca-path",
|
|
|
|
TLSServer: true,
|
2022-11-18 20:36:20 +00:00
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-grpc-ca-path", "../../../test/ca_path/"},
|
|
|
|
Env: []string{"CONSUL_GRPC_ADDR=https://127.0.0.1:8502"},
|
2020-09-08 10:16:16 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-09-08 10:16:16 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
AgentTLS: true,
|
|
|
|
},
|
|
|
|
AgentCAPEM: `-----BEGIN CERTIFICATE-----\nMIIFADCCAuqgAwIBAgIBATALBgkqhkiG9w0BAQswEzERMA8GA1UEAxMIQ2VydEF1\ndGgwHhcNMTUwNTExMjI0NjQzWhcNMjUwNTExMjI0NjU0WjATMREwDwYDVQQDEwhD\nZXJ0QXV0aDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALcMByyynHsA\n+K4PJwo5+XHygaEZAhPGvHiKQK2Cbc9NDm0ZTzx0rA/dRTZlvouhDyzcJHm+6R1F\nj6zQv7iaSC3qQtJiPnPsfZ+/0XhFZ3fQWMnfDiGbZpF1kJF01ofB6vnsuocFC0zG\naGC+SZiLAzs+QMP3Bebw1elCBIeoN+8NWnRYmLsYIaYGJGBSbNo/lCpLTuinofUn\nL3ehWEGv1INwpHnSVeN0Ml2GFe23d7PUlj/wNIHgUdpUR+KEJxIP3klwtsI3QpSH\nc4VjWdf4aIcka6K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d3mQH6O23ncmwxTcPUJe6xZaIRrDuzwUcyhLj5Z3faag/f\npFIIcHSiHRfoqHLGsGg+3swId/zVJSSDHr7pJUu7Cre+vZa63FqDaooqvnisrQID\nAQABo4IBADCB/TAdBgNVHQ4EFgQUo/nrOfqvbee2VklVKIFlyQEbuJUwgc0GA1Ud\nIwSBxTCBwoAUo/nrOfqvbee2VklVKIFlyQEbuJWhgZ6kgZswgZgxCzAJBgNVBAYT\nAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEcMBoGA1UE\nChMTSGFzaGlDb3JwIFRlc3QgQ2VydDEMMAoGA1UECxMDRGV2MRYwFAYDVQQDEw10\nZXN0LmludGVybmFsMSAwHgYJKoZIhvcNAQkBFhF0ZXN0QGludGVybmFsLmNvbYIJ\nAIewRMI8OnvTMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADa9fV9h\ngjapBlkNmu64WX0Ufub5dsJrdHS8672P30S7ILB7Mk0W8sL65IezRsZnG898yHf9\n2uzmz5OvNTM9K380g7xFlyobSVq+6yqmmSAlA/ptAcIIZT727P5jig/DB7fzJM3g\njctDlEGOmEe50GQXc25VKpcpjAsNQi5ER5gowQ0v3IXNZs+yU+LvxLHc0rUJ/XSp\nlFCAMOqd5uRoMOejnT51G6krvLNzPaQ3N9jQfNVY4Q0zfs0M+6dRWvqfqB9Vyq8/\nPOLMld+HyAZEBk9zK3ZVIXx6XS4dkDnSNR91njLq7eouf6M7+7s/oMQZZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----\n`,
|
2019-12-13 16:44:48 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-12-13 16:44:48 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-29 16:27:57 +00:00
|
|
|
{
|
|
|
|
Name: "custom-bootstrap",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// Add a completely custom bootstrap template. Never mind if this is
|
|
|
|
// invalid envoy config just as long as it works and gets the variables
|
|
|
|
// interplated.
|
|
|
|
"envoy_bootstrap_json_tpl": `
|
|
|
|
{
|
|
|
|
"admin": {
|
|
|
|
"access_log_path": "/dev/null",
|
|
|
|
"address": {
|
|
|
|
"socket_address": {
|
|
|
|
"address": "{{ .AdminBindAddress }}",
|
|
|
|
"port_value": {{ .AdminBindPort }}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"node": {
|
|
|
|
"cluster": "{{ .ProxyCluster }}",
|
|
|
|
"id": "{{ .ProxyID }}"
|
|
|
|
},
|
2019-08-16 14:30:17 +00:00
|
|
|
"custom_field": "foo"
|
2019-04-29 16:27:57 +00:00
|
|
|
}`,
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-29 16:27:57 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-29 16:27:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "extra_-single",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// Add a custom sections with interpolated variables. These are all
|
|
|
|
// invalid config syntax too but we are just testing they have the right
|
|
|
|
// effect.
|
|
|
|
"envoy_extra_static_clusters_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_cluster_1"
|
|
|
|
}`,
|
|
|
|
"envoy_extra_static_listeners_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_listener_1"
|
|
|
|
}`,
|
|
|
|
"envoy_extra_stats_sinks_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_sink_1"
|
|
|
|
}`,
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-29 16:27:57 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-29 16:27:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "extra_-multiple",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// Add a custom sections with interpolated variables. These are all
|
|
|
|
// invalid config syntax too but we are just testing they have the right
|
|
|
|
// effect.
|
|
|
|
"envoy_extra_static_clusters_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_cluster_1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "fake_cluster_2"
|
|
|
|
}`,
|
|
|
|
"envoy_extra_static_listeners_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_listener_1"
|
|
|
|
},{
|
|
|
|
"name": "fake_listener_2"
|
|
|
|
}`,
|
|
|
|
"envoy_extra_stats_sinks_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_sink_1"
|
|
|
|
} , { "name": "fake_sink_2" }`,
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-29 16:27:57 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-29 16:27:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "stats-config-override",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// Add a custom sections with interpolated variables. These are all
|
|
|
|
// invalid config syntax too but we are just testing they have the right
|
|
|
|
// effect.
|
|
|
|
"envoy_stats_config_json": `
|
|
|
|
{
|
|
|
|
"name": "fake_config"
|
|
|
|
}`,
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-29 16:27:57 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-29 16:27:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "zipkin-tracing-config",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ProxyConfig: map[string]interface{}{
|
|
|
|
// Add a custom sections with interpolated variables. These are all
|
|
|
|
// invalid config syntax too but we are just testing they have the right
|
|
|
|
// effect.
|
|
|
|
"envoy_tracing_json": `{
|
|
|
|
"http": {
|
|
|
|
"name": "envoy.zipkin",
|
|
|
|
"config": {
|
|
|
|
"collector_cluster": "zipkin",
|
|
|
|
"collector_endpoint": "/api/v1/spans"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
// Need to setup the cluster to send that too as well
|
|
|
|
"envoy_extra_static_clusters_json": `{
|
|
|
|
"name": "zipkin",
|
|
|
|
"type": "STRICT_DNS",
|
|
|
|
"connect_timeout": "5s",
|
|
|
|
"load_assignment": {
|
|
|
|
"cluster_name": "zipkin",
|
|
|
|
"endpoints": [
|
|
|
|
{
|
|
|
|
"lb_endpoints": [
|
|
|
|
{
|
|
|
|
"endpoint": {
|
|
|
|
"address": {
|
|
|
|
"socket_address": {
|
|
|
|
"address": "zipkin.service.consul",
|
|
|
|
"port_value": 9411
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-04-07 20:33:22 +00:00
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 20:33:22 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
2019-06-07 09:26:43 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2020-04-07 22:16:34 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-04-07 22:16:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-18 20:36:20 +00:00
|
|
|
Name: "CONSUL_HTTP_ADDR-with-https-scheme-does-not-affect-grpc-tls",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-ca-file", "../../../test/ca/root.cer"},
|
|
|
|
Env: []string{"CONSUL_HTTP_ADDR=https://127.0.0.1:8500"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
AgentTLS: false,
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "CONSUL_GRPC_ADDR-with-https-scheme-enables-tls",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-ca-file", "../../../test/ca/root.cer"},
|
|
|
|
Env: []string{"CONSUL_GRPC_ADDR=https://127.0.0.1:8502"},
|
2020-04-07 22:16:34 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
2020-11-16 23:37:19 +00:00
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
2020-04-07 22:16:34 +00:00
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
AgentTLS: true,
|
|
|
|
},
|
2022-11-18 20:36:20 +00:00
|
|
|
AgentCAPEM: `-----BEGIN CERTIFICATE-----\nMIIEtzCCA5+gAwIBAgIJAIewRMI8OnvTMA0GCSqGSIb3DQEBBQUAMIGYMQswCQYD\nVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xHDAa\nBgNVBAoTE0hhc2hpQ29ycCBUZXN0IENlcnQ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0ZXN0QGludGVybmFsLmNvbYIJ\nAIewRMI8OnvTMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADa9fV9h\ngjapBlkNmu64WX0Ufub5dsJrdHS8672P30S7ILB7Mk0W8sL65IezRsZnG898yHf9\n2uzmz5OvNTM9K380g7xFlyobSVq+6yqmmSAlA/ptAcIIZT727P5jig/DB7fzJM3g\njctDlEGOmEe50GQXc25VKpcpjAsNQi5ER5gowQ0v3IXNZs+yU+LvxLHc0rUJ/XSp\nlFCAMOqd5uRoMOejnT51G6krvLNzPaQ3N9jQfNVY4Q0zfs0M+6dRWvqfqB9Vyq8/\nPOLMld+HyAZEBk9zK3ZVIXx6XS4dkDnSNR91njLq7eouf6M7+7s/oMQZZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----\n`,
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "both-CONSUL_HTTP_ADDR-TLS-and-CONSUL_GRPC_ADDR-PLAIN-is-plain",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-ca-file", "../../../test/ca/root.cer"},
|
|
|
|
Env: []string{
|
|
|
|
"CONSUL_HTTP_ADDR=https://127.0.0.1:8500",
|
|
|
|
"CONSUL_GRPC_ADDR=http://127.0.0.1:8502",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
AgentTLS: false,
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "both-CONSUL_HTTP_ADDR-PLAIN-and-CONSUL_GRPC_ADDR-TLS-is-tls",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-ca-file", "../../../test/ca/root.cer"},
|
|
|
|
Env: []string{
|
|
|
|
"CONSUL_HTTP_ADDR=http://127.0.0.1:8500",
|
|
|
|
"CONSUL_GRPC_ADDR=https://127.0.0.1:8502",
|
|
|
|
},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
// Should resolve IP, note this might not resolve the same way
|
|
|
|
// everywhere which might make this test brittle but not sure what else
|
|
|
|
// to do.
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
AgentTLS: true,
|
|
|
|
},
|
|
|
|
AgentCAPEM: `-----BEGIN CERTIFICATE-----\nMIIEtzCCA5+gAwIBAgIJAIewRMI8OnvTMA0GCSqGSIb3DQEBBQUAMIGYMQswCQYD\nVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xHDAa\nBgNVBAoTE0hhc2hpQ29ycCBUZXN0IENlcnQxDDAKBgNVBAsTA0RldjEWMBQGA1UE\nAxMNdGVzdC5pbnR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EwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADa9fV9h\ngjapBlkNmu64WX0Ufub5dsJrdHS8672P30S7ILB7Mk0W8sL65IezRsZnG898yHf9\n2uzmz5OvNTM9K380g7xFlyobSVq+6yqmmSAlA/ptAcIIZT727P5jig/DB7fzJM3g\njctDlEGOmEe50GQXc25VKpcpjAsNQi5ER5gowQ0v3IXNZs+yU+LvxLHc0rUJ/XSp\nlFCAMOqd5uRoMOejnT51G6krvLNzPaQ3N9jQfNVY4Q0zfs0M+6dRWvqfqB9Vyq8/\nPOLMld+HyAZEBk9zK3ZVIXx6XS4dkDnSNR91njLq7eouf6M7+7s/oMQZZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----\n`,
|
2020-04-07 22:16:34 +00:00
|
|
|
AdminAccessLogPath: "/dev/null",
|
2020-04-14 14:48:02 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-04-14 14:48:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "ingress-gateway",
|
2020-05-13 17:56:53 +00:00
|
|
|
Flags: []string{"-proxy-id", "ingress-gateway-1", "-gateway", "ingress"},
|
2020-04-14 14:48:02 +00:00
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-11-16 23:37:19 +00:00
|
|
|
ProxyCluster: "ingress-gateway",
|
|
|
|
ProxyID: "ingress-gateway-1",
|
|
|
|
ProxySourceService: "ingress-gateway",
|
2020-04-14 14:48:02 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-04-14 14:48:02 +00:00
|
|
|
},
|
|
|
|
},
|
2022-06-06 16:23:08 +00:00
|
|
|
{
|
|
|
|
Name: "ingress-gateway-nodemeta",
|
|
|
|
Flags: []string{"-proxy-id", "ingress-gateway-1", "-node-name", "test-node"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "ingress-gateway-1",
|
|
|
|
ProxyID: "ingress-gateway-1",
|
|
|
|
NodeName: "test-node",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2023-01-19 21:54:11 +00:00
|
|
|
{
|
|
|
|
Name: "envoy-readiness-probe",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy",
|
|
|
|
"-envoy-ready-bind-address", "127.0.0.1", "-envoy-ready-bind-port", "21000"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2020-04-14 14:48:02 +00:00
|
|
|
{
|
|
|
|
Name: "ingress-gateway-address-specified",
|
|
|
|
Flags: []string{"-proxy-id", "ingress-gateway", "-gateway", "ingress", "-address", "1.2.3.4:7777"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-11-16 23:37:19 +00:00
|
|
|
ProxyCluster: "ingress-gateway",
|
|
|
|
ProxyID: "ingress-gateway",
|
|
|
|
ProxySourceService: "ingress-gateway",
|
2020-04-14 14:48:02 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
2019-04-29 16:27:57 +00:00
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2019-04-29 16:27:57 +00:00
|
|
|
},
|
|
|
|
},
|
2020-05-13 17:56:53 +00:00
|
|
|
{
|
|
|
|
Name: "ingress-gateway-register-with-service-without-proxy-id",
|
|
|
|
Flags: []string{"-gateway", "ingress", "-register", "-service", "my-gateway", "-address", "127.0.0.1:7777"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-11-16 23:37:19 +00:00
|
|
|
ProxyCluster: "my-gateway",
|
|
|
|
ProxyID: "my-gateway",
|
|
|
|
ProxySourceService: "my-gateway",
|
2020-05-13 17:56:53 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-05-13 17:56:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "ingress-gateway-register-with-service-and-proxy-id",
|
|
|
|
Flags: []string{"-gateway", "ingress", "-register", "-service", "my-gateway", "-proxy-id", "my-gateway-123", "-address", "127.0.0.1:7777"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-11-16 23:37:19 +00:00
|
|
|
ProxyCluster: "my-gateway",
|
|
|
|
ProxyID: "my-gateway-123",
|
|
|
|
ProxySourceService: "my-gateway",
|
2020-05-13 17:56:53 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-05-13 17:56:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "ingress-gateway-no-auto-register",
|
|
|
|
Flags: []string{"-gateway", "ingress", "-address", "127.0.0.1:7777"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
2020-11-16 23:37:19 +00:00
|
|
|
ProxyCluster: "ingress-gateway",
|
|
|
|
ProxyID: "ingress-gateway",
|
|
|
|
ProxySourceService: "ingress-gateway",
|
2020-05-13 17:56:53 +00:00
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
2021-03-04 22:15:47 +00:00
|
|
|
PrometheusScrapePath: "/metrics",
|
2020-05-13 17:56:53 +00:00
|
|
|
},
|
|
|
|
},
|
2023-01-09 20:16:00 +00:00
|
|
|
{
|
|
|
|
Name: "access-logs-enabled",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
ProxyDefaults: api.ProxyConfigEntry{
|
|
|
|
AccessLogs: &api.AccessLogsConfig{
|
|
|
|
Enabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "access-logs-enabled-custom",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502",
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
ProxyDefaults: api.ProxyConfigEntry{
|
|
|
|
AccessLogs: &api.AccessLogsConfig{
|
|
|
|
Enabled: true,
|
|
|
|
DisableListenerLogs: true, // Should have no effect here
|
|
|
|
Type: api.FileLogSinkType,
|
|
|
|
Path: "/var/log/consul.log",
|
|
|
|
TextFormat: "MY START TIME %START_TIME%",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-01-16 17:31:56 +00:00
|
|
|
{
|
|
|
|
Name: "acl-enabled-but-no-token",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy"},
|
|
|
|
ACLEnabled: true,
|
|
|
|
WantWarn: "No ACL token was provided to Envoy.",
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "acl-enabled-and-token",
|
|
|
|
Flags: []string{"-proxy-id", "test-proxy", "-token", "foo"},
|
|
|
|
ACLEnabled: true,
|
|
|
|
WantArgs: BootstrapTplArgs{
|
|
|
|
ProxyCluster: "test-proxy",
|
|
|
|
ProxyID: "test-proxy",
|
|
|
|
// We don't know this til after the lookup so it will be empty in the
|
|
|
|
// initial args call we are testing here.
|
|
|
|
ProxySourceService: "",
|
|
|
|
GRPC: GRPC{
|
|
|
|
AgentAddress: "127.0.0.1",
|
|
|
|
AgentPort: "8502", // Note this is the gRPC port
|
|
|
|
},
|
|
|
|
AdminAccessLogPath: "/dev/null",
|
|
|
|
AdminBindAddress: "127.0.0.1",
|
|
|
|
AdminBindPort: "19000",
|
|
|
|
Token: "foo",
|
|
|
|
LocalAgentClusterName: xds.LocalAgentClusterName,
|
|
|
|
PrometheusBackendPort: "",
|
|
|
|
PrometheusScrapePath: "/metrics",
|
|
|
|
},
|
|
|
|
},
|
2018-10-09 09:57:26 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
cases = append(cases, enterpriseGenerateConfigTestCases()...)
|
|
|
|
|
2019-04-30 14:59:00 +00:00
|
|
|
copyAndReplaceAll := func(s []string, old, new string) []string {
|
|
|
|
out := make([]string, len(s))
|
|
|
|
for i, v := range s {
|
|
|
|
out[i] = strings.ReplaceAll(v, old, new)
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2018-10-09 09:57:26 +00:00
|
|
|
for _, tc := range cases {
|
|
|
|
t.Run(tc.Name, func(t *testing.T) {
|
|
|
|
|
2019-04-30 14:59:00 +00:00
|
|
|
testDir := testutil.TempDir(t, "envoytest")
|
|
|
|
|
|
|
|
if len(tc.Files) > 0 {
|
|
|
|
for fn, fv := range tc.Files {
|
|
|
|
fullname := filepath.Join(testDir, fn)
|
2022-11-10 16:26:01 +00:00
|
|
|
require.NoError(t, os.WriteFile(fullname, []byte(fv), 0600))
|
2019-04-30 14:59:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-19 19:37:27 +00:00
|
|
|
// Default the ports
|
|
|
|
if tc.XDSPorts.TLS == 0 && tc.XDSPorts.Plaintext == 0 {
|
|
|
|
tc.XDSPorts.Plaintext = 8502
|
|
|
|
}
|
|
|
|
|
2019-04-29 16:27:57 +00:00
|
|
|
// Run a mock agent API that just always returns the proxy config in the
|
|
|
|
// test.
|
2021-09-15 23:22:22 +00:00
|
|
|
var srv *httptest.Server
|
|
|
|
if tc.TLSServer {
|
|
|
|
srv = httptest.NewTLSServer(testMockAgent(tc))
|
|
|
|
} else {
|
|
|
|
srv = httptest.NewServer(testMockAgent(tc))
|
|
|
|
}
|
2019-04-29 16:27:57 +00:00
|
|
|
defer srv.Close()
|
|
|
|
|
2019-04-30 14:59:00 +00:00
|
|
|
testDirPrefix := testDir + string(filepath.Separator)
|
|
|
|
myEnv := copyAndReplaceAll(tc.Env, "@@TEMPDIR@@", testDirPrefix)
|
|
|
|
defer testSetAndResetEnv(t, myEnv)()
|
2018-10-09 09:57:26 +00:00
|
|
|
|
2021-09-15 23:22:22 +00:00
|
|
|
client, err := api.NewClient(&api.Config{Address: srv.URL, TLSConfig: api.TLSConfig{InsecureSkipVerify: true}})
|
bulk rewrite using this script
set -euo pipefail
unset CDPATH
cd "$(dirname "$0")"
for f in $(git grep '\brequire := require\.New(' | cut -d':' -f1 | sort -u); do
echo "=== require: $f ==="
sed -i '/require := require.New(t)/d' $f
# require.XXX(blah) but not require.XXX(tblah) or require.XXX(rblah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\([^tr]\)/require.\1(t,\2/g' $f
# require.XXX(tblah) but not require.XXX(t, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/require.\1(t,\2/g' $f
# require.XXX(rblah) but not require.XXX(r, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/require.\1(t,\2/g' $f
gofmt -s -w $f
done
for f in $(git grep '\bassert := assert\.New(' | cut -d':' -f1 | sort -u); do
echo "=== assert: $f ==="
sed -i '/assert := assert.New(t)/d' $f
# assert.XXX(blah) but not assert.XXX(tblah) or assert.XXX(rblah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\([^tr]\)/assert.\1(t,\2/g' $f
# assert.XXX(tblah) but not assert.XXX(t, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/assert.\1(t,\2/g' $f
# assert.XXX(rblah) but not assert.XXX(r, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/assert.\1(t,\2/g' $f
gofmt -s -w $f
done
2022-01-20 16:46:23 +00:00
|
|
|
require.NoError(t, err)
|
2021-09-15 23:22:22 +00:00
|
|
|
|
2020-03-23 14:49:50 +00:00
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
2020-04-07 22:02:56 +00:00
|
|
|
// explicitly set the client to one which can connect to the httptest.Server
|
|
|
|
c.client = client
|
2020-03-23 14:49:50 +00:00
|
|
|
|
2023-01-06 18:34:49 +00:00
|
|
|
c.dialFunc = func(_, _ string) (net.Conn, error) {
|
|
|
|
return nil, nil
|
2022-12-19 19:37:27 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 09:57:26 +00:00
|
|
|
// Run the command
|
2020-03-23 14:49:50 +00:00
|
|
|
myFlags := copyAndReplaceAll(tc.Flags, "@@TEMPDIR@@", testDirPrefix)
|
2019-04-30 14:59:00 +00:00
|
|
|
args := append([]string{"-bootstrap"}, myFlags...)
|
2020-04-07 22:02:56 +00:00
|
|
|
|
bulk rewrite using this script
set -euo pipefail
unset CDPATH
cd "$(dirname "$0")"
for f in $(git grep '\brequire := require\.New(' | cut -d':' -f1 | sort -u); do
echo "=== require: $f ==="
sed -i '/require := require.New(t)/d' $f
# require.XXX(blah) but not require.XXX(tblah) or require.XXX(rblah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\([^tr]\)/require.\1(t,\2/g' $f
# require.XXX(tblah) but not require.XXX(t, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/require.\1(t,\2/g' $f
# require.XXX(rblah) but not require.XXX(r, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/require.\1(t,\2/g' $f
gofmt -s -w $f
done
for f in $(git grep '\bassert := assert\.New(' | cut -d':' -f1 | sort -u); do
echo "=== assert: $f ==="
sed -i '/assert := assert.New(t)/d' $f
# assert.XXX(blah) but not assert.XXX(tblah) or assert.XXX(rblah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\([^tr]\)/assert.\1(t,\2/g' $f
# assert.XXX(tblah) but not assert.XXX(t, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/assert.\1(t,\2/g' $f
# assert.XXX(rblah) but not assert.XXX(r, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/assert.\1(t,\2/g' $f
gofmt -s -w $f
done
2022-01-20 16:46:23 +00:00
|
|
|
require.NoError(t, c.flags.Parse(args))
|
2020-04-07 22:02:56 +00:00
|
|
|
code := c.run(c.flags.Args())
|
2023-01-16 17:31:56 +00:00
|
|
|
if tc.WantErr != "" {
|
bulk rewrite using this script
set -euo pipefail
unset CDPATH
cd "$(dirname "$0")"
for f in $(git grep '\brequire := require\.New(' | cut -d':' -f1 | sort -u); do
echo "=== require: $f ==="
sed -i '/require := require.New(t)/d' $f
# require.XXX(blah) but not require.XXX(tblah) or require.XXX(rblah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\([^tr]\)/require.\1(t,\2/g' $f
# require.XXX(tblah) but not require.XXX(t, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/require.\1(t,\2/g' $f
# require.XXX(rblah) but not require.XXX(r, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/require.\1(t,\2/g' $f
gofmt -s -w $f
done
for f in $(git grep '\bassert := assert\.New(' | cut -d':' -f1 | sort -u); do
echo "=== assert: $f ==="
sed -i '/assert := assert.New(t)/d' $f
# assert.XXX(blah) but not assert.XXX(tblah) or assert.XXX(rblah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\([^tr]\)/assert.\1(t,\2/g' $f
# assert.XXX(tblah) but not assert.XXX(t, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/assert.\1(t,\2/g' $f
# assert.XXX(rblah) but not assert.XXX(r, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/assert.\1(t,\2/g' $f
gofmt -s -w $f
done
2022-01-20 16:46:23 +00:00
|
|
|
require.Equal(t, 1, code, ui.ErrorWriter.String())
|
|
|
|
require.Contains(t, ui.ErrorWriter.String(), tc.WantErr)
|
2018-10-09 09:57:26 +00:00
|
|
|
return
|
2023-01-16 17:31:56 +00:00
|
|
|
} else if tc.WantWarn != "" {
|
|
|
|
require.Equal(t, 0, code, ui.ErrorWriter.String())
|
|
|
|
require.Contains(t, ui.ErrorWriter.String(), tc.WantWarn)
|
|
|
|
} else {
|
|
|
|
require.Equal(t, 0, code, ui.ErrorWriter.String())
|
|
|
|
require.Empty(t, ui.ErrorWriter.String())
|
2018-10-09 09:57:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify we handled the env and flags right first to get correct template
|
|
|
|
// args.
|
|
|
|
got, err := c.templateArgs()
|
bulk rewrite using this script
set -euo pipefail
unset CDPATH
cd "$(dirname "$0")"
for f in $(git grep '\brequire := require\.New(' | cut -d':' -f1 | sort -u); do
echo "=== require: $f ==="
sed -i '/require := require.New(t)/d' $f
# require.XXX(blah) but not require.XXX(tblah) or require.XXX(rblah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\([^tr]\)/require.\1(t,\2/g' $f
# require.XXX(tblah) but not require.XXX(t, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/require.\1(t,\2/g' $f
# require.XXX(rblah) but not require.XXX(r, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/require.\1(t,\2/g' $f
gofmt -s -w $f
done
for f in $(git grep '\bassert := assert\.New(' | cut -d':' -f1 | sort -u); do
echo "=== assert: $f ==="
sed -i '/assert := assert.New(t)/d' $f
# assert.XXX(blah) but not assert.XXX(tblah) or assert.XXX(rblah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\([^tr]\)/assert.\1(t,\2/g' $f
# assert.XXX(tblah) but not assert.XXX(t, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/assert.\1(t,\2/g' $f
# assert.XXX(rblah) but not assert.XXX(r, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/assert.\1(t,\2/g' $f
gofmt -s -w $f
done
2022-01-20 16:46:23 +00:00
|
|
|
require.NoError(t, err) // Error cases should have returned above
|
|
|
|
require.Equal(t, &tc.WantArgs, got)
|
2018-10-09 09:57:26 +00:00
|
|
|
|
2021-04-07 19:22:52 +00:00
|
|
|
actual := ui.OutputWriter.Bytes()
|
2018-10-09 09:57:26 +00:00
|
|
|
|
|
|
|
// If we got the arg handling write, verify output
|
|
|
|
golden := filepath.Join("testdata", tc.Name+".golden")
|
|
|
|
if *update {
|
2022-11-10 16:26:01 +00:00
|
|
|
os.WriteFile(golden, actual, 0644)
|
2018-10-09 09:57:26 +00:00
|
|
|
}
|
|
|
|
|
2022-11-10 16:26:01 +00:00
|
|
|
expected, err := os.ReadFile(golden)
|
bulk rewrite using this script
set -euo pipefail
unset CDPATH
cd "$(dirname "$0")"
for f in $(git grep '\brequire := require\.New(' | cut -d':' -f1 | sort -u); do
echo "=== require: $f ==="
sed -i '/require := require.New(t)/d' $f
# require.XXX(blah) but not require.XXX(tblah) or require.XXX(rblah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\([^tr]\)/require.\1(t,\2/g' $f
# require.XXX(tblah) but not require.XXX(t, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/require.\1(t,\2/g' $f
# require.XXX(rblah) but not require.XXX(r, blah)
sed -i 's/\brequire\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/require.\1(t,\2/g' $f
gofmt -s -w $f
done
for f in $(git grep '\bassert := assert\.New(' | cut -d':' -f1 | sort -u); do
echo "=== assert: $f ==="
sed -i '/assert := assert.New(t)/d' $f
# assert.XXX(blah) but not assert.XXX(tblah) or assert.XXX(rblah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\([^tr]\)/assert.\1(t,\2/g' $f
# assert.XXX(tblah) but not assert.XXX(t, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(t[^,]\)/assert.\1(t,\2/g' $f
# assert.XXX(rblah) but not assert.XXX(r, blah)
sed -i 's/\bassert\.\([a-zA-Z0-9_]*\)(\(r[^,]\)/assert.\1(t,\2/g' $f
gofmt -s -w $f
done
2022-01-20 16:46:23 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, string(expected), string(actual))
|
2018-10-09 09:57:26 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 16:27:57 +00:00
|
|
|
|
2020-05-13 17:56:53 +00:00
|
|
|
func TestEnvoy_GatewayRegistration(t *testing.T) {
|
2020-12-07 18:42:55 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
2020-05-13 17:56:53 +00:00
|
|
|
t.Parallel()
|
|
|
|
a := agent.NewTestAgent(t, ``)
|
|
|
|
defer a.Shutdown()
|
|
|
|
client := a.Client()
|
|
|
|
|
|
|
|
tt := []struct {
|
|
|
|
name string
|
|
|
|
args []string
|
|
|
|
kind api.ServiceKind
|
|
|
|
id string
|
|
|
|
service string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "register gateway with proxy-id and name",
|
|
|
|
args: []string{
|
|
|
|
"-http-addr=" + a.HTTPAddr(),
|
|
|
|
"-register",
|
|
|
|
"-bootstrap",
|
|
|
|
"-gateway", "ingress",
|
|
|
|
"-service", "us-ingress",
|
|
|
|
"-proxy-id", "us-ingress-1",
|
|
|
|
},
|
|
|
|
kind: api.ServiceKindIngressGateway,
|
|
|
|
id: "us-ingress-1",
|
|
|
|
service: "us-ingress",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "register gateway without proxy-id with name",
|
|
|
|
args: []string{
|
|
|
|
"-http-addr=" + a.HTTPAddr(),
|
|
|
|
"-register",
|
|
|
|
"-bootstrap",
|
|
|
|
"-gateway", "ingress",
|
|
|
|
"-service", "us-ingress",
|
|
|
|
},
|
|
|
|
kind: api.ServiceKindIngressGateway,
|
|
|
|
id: "us-ingress",
|
|
|
|
service: "us-ingress",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "register gateway without proxy-id and without name",
|
|
|
|
args: []string{
|
|
|
|
"-http-addr=" + a.HTTPAddr(),
|
|
|
|
"-register",
|
|
|
|
"-bootstrap",
|
|
|
|
"-gateway", "ingress",
|
|
|
|
},
|
|
|
|
kind: api.ServiceKindIngressGateway,
|
|
|
|
id: "ingress-gateway",
|
|
|
|
service: "ingress-gateway",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "register gateway with proxy-id without name",
|
|
|
|
args: []string{
|
|
|
|
"-http-addr=" + a.HTTPAddr(),
|
|
|
|
"-register",
|
|
|
|
"-bootstrap",
|
|
|
|
"-gateway", "ingress",
|
|
|
|
"-proxy-id", "us-ingress-1",
|
|
|
|
},
|
|
|
|
kind: api.ServiceKindIngressGateway,
|
|
|
|
id: "us-ingress-1",
|
|
|
|
service: "ingress-gateway",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tt {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
|
|
|
|
code := c.Run(tc.args)
|
|
|
|
if code != 0 {
|
|
|
|
t.Fatalf("bad exit code: %d. %#v", code, ui.ErrorWriter.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
data, _, err := client.Agent().Service(tc.id, nil)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
assert.NotNil(t, data)
|
|
|
|
assert.Equal(t, tc.kind, data.Kind)
|
|
|
|
assert.Equal(t, tc.id, data.ID)
|
|
|
|
assert.Equal(t, tc.service, data.Service)
|
|
|
|
assert.Equal(t, defaultGatewayPort, data.Port)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 16:53:34 +00:00
|
|
|
// testMockAgent combines testMockAgentProxyConfig and testMockAgentSelf,
|
2022-06-06 16:23:08 +00:00
|
|
|
// routing /agent/service/... requests to testMockAgentProxyConfig,
|
|
|
|
// routing /catalog/node-services/... requests to testMockCatalogNodeServiceList
|
2019-08-01 16:53:34 +00:00
|
|
|
// routing /agent/self requests to testMockAgentSelf.
|
2021-07-09 19:17:29 +00:00
|
|
|
func testMockAgent(tc generateConfigTestCase) http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
switch {
|
|
|
|
case strings.Contains(r.URL.Path, "/agent/services"):
|
|
|
|
testMockAgentGatewayConfig(tc.NamespacesEnabled)(w, r)
|
|
|
|
case strings.Contains(r.URL.Path, "/agent/service"):
|
|
|
|
testMockAgentProxyConfig(tc.ProxyConfig, tc.NamespacesEnabled)(w, r)
|
|
|
|
case strings.Contains(r.URL.Path, "/agent/self"):
|
2023-03-06 15:32:06 +00:00
|
|
|
testMockAgentSelf(tc.XDSPorts, tc.AgentSelf110, tc.GRPCDisabled)(w, r)
|
2022-06-06 16:23:08 +00:00
|
|
|
case strings.Contains(r.URL.Path, "/catalog/node-services"):
|
|
|
|
testMockCatalogNodeServiceList()(w, r)
|
2023-01-09 20:16:00 +00:00
|
|
|
case strings.Contains(r.URL.Path, "/config/proxy-defaults/global"):
|
|
|
|
testMockConfigProxyDefaults(tc.ProxyDefaults)(w, r)
|
2023-01-16 17:31:56 +00:00
|
|
|
case strings.Contains(r.URL.Path, "/acl/token/self"):
|
|
|
|
testMockTokenReadSelf(tc.ACLEnabled, tc.Flags)(w, r)
|
2021-07-09 19:17:29 +00:00
|
|
|
default:
|
|
|
|
http.NotFound(w, r)
|
2019-08-01 16:53:34 +00:00
|
|
|
}
|
2021-07-09 19:17:29 +00:00
|
|
|
}
|
2019-08-01 16:53:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
func testMockAgentGatewayConfig(namespacesEnabled bool) http.HandlerFunc {
|
2021-07-09 19:17:29 +00:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2020-05-13 17:56:53 +00:00
|
|
|
// Parse the proxy-id from the end of the URL (blindly assuming it's correct
|
|
|
|
// format)
|
|
|
|
params := r.URL.Query()
|
|
|
|
filter := params["filter"][0]
|
|
|
|
|
|
|
|
var kind api.ServiceKind
|
|
|
|
switch {
|
|
|
|
case strings.Contains(filter, string(api.ServiceKindTerminatingGateway)):
|
|
|
|
kind = api.ServiceKindTerminatingGateway
|
|
|
|
case strings.Contains(filter, string(api.ServiceKindIngressGateway)):
|
|
|
|
kind = api.ServiceKindIngressGateway
|
|
|
|
}
|
|
|
|
|
|
|
|
svc := map[string]*api.AgentService{
|
|
|
|
string(kind): {
|
2020-11-19 21:27:31 +00:00
|
|
|
Kind: kind,
|
|
|
|
ID: string(kind),
|
|
|
|
Service: string(kind),
|
|
|
|
Datacenter: "dc1",
|
2020-05-13 17:56:53 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
if namespacesEnabled {
|
|
|
|
svc[string(kind)].Namespace = namespaceFromQuery(r)
|
2021-09-15 23:22:22 +00:00
|
|
|
svc[string(kind)].Partition = partitionFromQuery(r)
|
2020-11-16 23:37:19 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 17:56:53 +00:00
|
|
|
cfgJSON, err := json.Marshal(svc)
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(500)
|
|
|
|
w.Write([]byte(err.Error()))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Write(cfgJSON)
|
2021-07-09 19:17:29 +00:00
|
|
|
}
|
2020-05-13 17:56:53 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
func namespaceFromQuery(r *http.Request) string {
|
|
|
|
// Use the namespace in the request if there is one, otherwise
|
|
|
|
// use-default.
|
|
|
|
if queryNs := r.URL.Query().Get("ns"); queryNs != "" {
|
|
|
|
return queryNs
|
|
|
|
}
|
|
|
|
return "default"
|
|
|
|
}
|
|
|
|
|
2021-09-15 23:22:22 +00:00
|
|
|
func partitionFromQuery(r *http.Request) string {
|
|
|
|
// Use the partition in the request if there is one, otherwise
|
|
|
|
// use-default.
|
|
|
|
if queryAP := r.URL.Query().Get("partition"); queryAP != "" {
|
|
|
|
return queryAP
|
|
|
|
}
|
|
|
|
return "default"
|
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
func testMockAgentProxyConfig(cfg map[string]interface{}, namespacesEnabled bool) http.HandlerFunc {
|
2021-07-09 19:17:29 +00:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2019-04-29 16:27:57 +00:00
|
|
|
// Parse the proxy-id from the end of the URL (blindly assuming it's correct
|
|
|
|
// format)
|
|
|
|
proxyID := strings.TrimPrefix(r.URL.Path, "/v1/agent/service/")
|
2022-06-06 16:23:08 +00:00
|
|
|
serviceID := strings.TrimSuffix(proxyID, "-proxy")
|
2019-04-29 16:27:57 +00:00
|
|
|
|
|
|
|
svc := api.AgentService{
|
|
|
|
Kind: api.ServiceKindConnectProxy,
|
|
|
|
ID: proxyID,
|
|
|
|
Service: proxyID,
|
|
|
|
Proxy: &api.AgentServiceConnectProxyConfig{
|
|
|
|
DestinationServiceName: serviceID,
|
|
|
|
DestinationServiceID: serviceID,
|
|
|
|
Config: cfg,
|
|
|
|
},
|
2020-11-19 21:27:31 +00:00
|
|
|
Datacenter: "dc1",
|
2019-04-29 16:27:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 23:37:19 +00:00
|
|
|
if namespacesEnabled {
|
|
|
|
svc.Namespace = namespaceFromQuery(r)
|
2021-09-15 23:22:22 +00:00
|
|
|
svc.Partition = partitionFromQuery(r)
|
2020-11-16 23:37:19 +00:00
|
|
|
}
|
|
|
|
|
2019-04-29 16:27:57 +00:00
|
|
|
cfgJSON, err := json.Marshal(svc)
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(500)
|
|
|
|
w.Write([]byte(err.Error()))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Write(cfgJSON)
|
2021-07-09 19:17:29 +00:00
|
|
|
}
|
2019-04-29 16:27:57 +00:00
|
|
|
}
|
2019-07-30 13:56:56 +00:00
|
|
|
|
2022-06-06 16:23:08 +00:00
|
|
|
func testMockCatalogNodeServiceList() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
quotedProxyID := strings.TrimPrefix(r.URL.Query().Get("filter"), "ID == ")
|
|
|
|
proxyID := quotedProxyID[1 : len(quotedProxyID)-1]
|
|
|
|
serviceID := strings.TrimSuffix(proxyID, "-proxy")
|
|
|
|
|
|
|
|
var svcKind api.ServiceKind
|
|
|
|
if strings.Contains(proxyID, "ingress-gateway") {
|
|
|
|
svcKind = api.ServiceKindIngressGateway
|
|
|
|
} else {
|
|
|
|
svcKind = api.ServiceKindConnectProxy
|
|
|
|
}
|
|
|
|
|
|
|
|
var svcProxy api.AgentServiceConnectProxyConfig
|
|
|
|
if svcKind == api.ServiceKindConnectProxy {
|
|
|
|
svcProxy = api.AgentServiceConnectProxyConfig{
|
|
|
|
DestinationServiceName: serviceID,
|
|
|
|
DestinationServiceID: serviceID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
svc := api.AgentService{
|
|
|
|
Kind: svcKind,
|
|
|
|
ID: proxyID,
|
|
|
|
Service: proxyID,
|
|
|
|
Proxy: &svcProxy,
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeSvc := api.CatalogNodeServiceList{
|
|
|
|
Node: &api.Node{Datacenter: "dc1"},
|
|
|
|
Services: []*api.AgentService{&svc},
|
|
|
|
}
|
|
|
|
|
|
|
|
cfgJSON, err := json.Marshal(nodeSvc)
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(500)
|
|
|
|
w.Write([]byte(err.Error()))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Write(cfgJSON)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-09 20:16:00 +00:00
|
|
|
func testMockConfigProxyDefaults(entry api.ProxyConfigEntry) http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
cfgJSON, err := json.Marshal(entry)
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(500)
|
|
|
|
w.Write([]byte(err.Error()))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Write(cfgJSON)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-16 17:31:56 +00:00
|
|
|
func testMockTokenReadSelf(aclEnabled bool, flags []string) http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if aclEnabled {
|
|
|
|
for _, f := range flags {
|
|
|
|
if f == "-token" {
|
|
|
|
w.WriteHeader(200)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w.WriteHeader(403)
|
|
|
|
w.Write([]byte(acl.ErrNotFound.Error()))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-30 13:56:56 +00:00
|
|
|
func TestEnvoyCommand_canBindInternal(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
type testCheck struct {
|
|
|
|
expected bool
|
|
|
|
addr string
|
|
|
|
}
|
|
|
|
|
|
|
|
type testCase struct {
|
|
|
|
ifAddrs []net.Addr
|
|
|
|
checks map[string]testCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
parseIPNets := func(t *testing.T, in ...string) []net.Addr {
|
|
|
|
var out []net.Addr
|
|
|
|
for _, addr := range in {
|
|
|
|
ip := net.ParseIP(addr)
|
|
|
|
require.NotNil(t, ip)
|
|
|
|
out = append(out, &net.IPNet{IP: ip})
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
parseIPs := func(t *testing.T, in ...string) []net.Addr {
|
|
|
|
var out []net.Addr
|
|
|
|
for _, addr := range in {
|
|
|
|
ip := net.ParseIP(addr)
|
|
|
|
require.NotNil(t, ip)
|
|
|
|
out = append(out, &net.IPAddr{IP: ip})
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
cases := map[string]testCase{
|
|
|
|
"IPNet": {
|
|
|
|
parseIPNets(t, "10.3.0.2", "198.18.0.1", "2001:db8:a0b:12f0::1"),
|
|
|
|
map[string]testCheck{
|
|
|
|
"ipv4": {
|
|
|
|
true,
|
|
|
|
"10.3.0.2",
|
|
|
|
},
|
|
|
|
"secondary ipv4": {
|
|
|
|
true,
|
|
|
|
"198.18.0.1",
|
|
|
|
},
|
|
|
|
"ipv6": {
|
|
|
|
true,
|
|
|
|
"2001:db8:a0b:12f0::1",
|
|
|
|
},
|
|
|
|
"ipv4 not found": {
|
|
|
|
false,
|
|
|
|
"1.2.3.4",
|
|
|
|
},
|
|
|
|
"ipv6 not found": {
|
|
|
|
false,
|
|
|
|
"::ffff:192.168.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"IPAddr": {
|
|
|
|
parseIPs(t, "10.3.0.2", "198.18.0.1", "2001:db8:a0b:12f0::1"),
|
|
|
|
map[string]testCheck{
|
|
|
|
"ipv4": {
|
|
|
|
true,
|
|
|
|
"10.3.0.2",
|
|
|
|
},
|
|
|
|
"secondary ipv4": {
|
|
|
|
true,
|
|
|
|
"198.18.0.1",
|
|
|
|
},
|
|
|
|
"ipv6": {
|
|
|
|
true,
|
|
|
|
"2001:db8:a0b:12f0::1",
|
|
|
|
},
|
|
|
|
"ipv4 not found": {
|
|
|
|
false,
|
|
|
|
"1.2.3.4",
|
|
|
|
},
|
|
|
|
"ipv6 not found": {
|
|
|
|
false,
|
|
|
|
"::ffff:192.168.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tcase := range cases {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
for checkName, check := range tcase.checks {
|
|
|
|
t.Run(checkName, func(t *testing.T) {
|
|
|
|
require.Equal(t, check.expected, canBindInternal(check.addr, tcase.ifAddrs))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-08-02 21:19:56 +00:00
|
|
|
|
2019-08-01 16:53:34 +00:00
|
|
|
// testMockAgentSelf returns an empty /v1/agent/self response except GRPC
|
2021-07-09 19:17:29 +00:00
|
|
|
// port is filled in to match the given wantXDSPort argument.
|
2023-03-06 15:32:06 +00:00
|
|
|
func testMockAgentSelf(
|
|
|
|
wantXDSPorts agent.GRPCPorts,
|
|
|
|
agentSelf110 bool,
|
|
|
|
grpcDisabled bool,
|
|
|
|
) http.HandlerFunc {
|
2021-07-09 19:17:29 +00:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2019-08-01 16:53:34 +00:00
|
|
|
resp := agent.Self{
|
2020-11-16 23:37:19 +00:00
|
|
|
Config: map[string]interface{}{
|
|
|
|
"Datacenter": "dc1",
|
|
|
|
},
|
2021-07-09 19:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if agentSelf110 {
|
|
|
|
resp.DebugConfig = map[string]interface{}{
|
2022-09-01 17:32:11 +00:00
|
|
|
"GRPCPort": wantXDSPorts.Plaintext,
|
2021-07-09 19:17:29 +00:00
|
|
|
}
|
2023-03-06 15:32:06 +00:00
|
|
|
} else if grpcDisabled {
|
|
|
|
resp.DebugConfig = map[string]interface{}{
|
|
|
|
"GRPCPort": -1,
|
|
|
|
}
|
|
|
|
// the real agent does not populate XDS if grpc or
|
|
|
|
// grpc-tls ports are < 0
|
2021-07-09 19:17:29 +00:00
|
|
|
} else {
|
2022-09-01 17:32:11 +00:00
|
|
|
resp.XDS = &agent.XDSSelf{
|
|
|
|
// The deprecated Port field should default to TLS if it's available.
|
|
|
|
Port: wantXDSPorts.TLS,
|
|
|
|
Ports: wantXDSPorts,
|
|
|
|
}
|
|
|
|
if wantXDSPorts.TLS <= 0 {
|
|
|
|
resp.XDS.Port = wantXDSPorts.Plaintext
|
|
|
|
}
|
2019-08-01 16:53:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
selfJSON, err := json.Marshal(resp)
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(500)
|
|
|
|
w.Write([]byte(err.Error()))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Write(selfJSON)
|
2021-07-09 19:17:29 +00:00
|
|
|
}
|
2019-08-01 16:53:34 +00:00
|
|
|
}
|
2022-12-20 17:58:19 +00:00
|
|
|
|
|
|
|
func TestCheckEnvoyVersionCompatibility(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
envoyVersion string
|
|
|
|
unsupportedList []string
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat envoyCompat
|
2022-12-20 17:58:19 +00:00
|
|
|
isErrorExpected bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "supported-using-proxy-support-defined",
|
2023-02-06 17:14:35 +00:00
|
|
|
envoyVersion: xdscommon.EnvoyVersions[1],
|
|
|
|
unsupportedList: xdscommon.UnsupportedEnvoyVersions,
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{
|
|
|
|
isCompatible: true,
|
|
|
|
},
|
2022-12-20 17:58:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "supported-at-max",
|
2023-02-06 17:14:35 +00:00
|
|
|
envoyVersion: xdscommon.GetMaxEnvoyMinorVersion(),
|
|
|
|
unsupportedList: xdscommon.UnsupportedEnvoyVersions,
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{
|
|
|
|
isCompatible: true,
|
|
|
|
},
|
2022-12-20 17:58:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "supported-patch-higher",
|
2023-02-06 17:14:35 +00:00
|
|
|
envoyVersion: addNPatchVersion(xdscommon.EnvoyVersions[0], 1),
|
|
|
|
unsupportedList: xdscommon.UnsupportedEnvoyVersions,
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{
|
|
|
|
isCompatible: true,
|
|
|
|
},
|
2022-12-20 17:58:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "not-supported-minor-higher",
|
2023-02-06 17:14:35 +00:00
|
|
|
envoyVersion: addNMinorVersion(xdscommon.EnvoyVersions[0], 1),
|
|
|
|
unsupportedList: xdscommon.UnsupportedEnvoyVersions,
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{
|
|
|
|
isCompatible: false,
|
|
|
|
versionIncompatible: replacePatchVersionWithX(addNMinorVersion(xdscommon.EnvoyVersions[0], 1)),
|
|
|
|
},
|
2022-12-20 17:58:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "not-supported-minor-lower",
|
2023-02-06 17:14:35 +00:00
|
|
|
envoyVersion: addNMinorVersion(xdscommon.EnvoyVersions[len(xdscommon.EnvoyVersions)-1], -1),
|
|
|
|
unsupportedList: xdscommon.UnsupportedEnvoyVersions,
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{
|
|
|
|
isCompatible: false,
|
|
|
|
versionIncompatible: replacePatchVersionWithX(addNMinorVersion(xdscommon.EnvoyVersions[len(xdscommon.EnvoyVersions)-1], -1)),
|
|
|
|
},
|
2022-12-20 17:58:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "not-supported-explicitly-unsupported-version",
|
2023-02-06 17:14:35 +00:00
|
|
|
envoyVersion: addNPatchVersion(xdscommon.EnvoyVersions[0], 1),
|
|
|
|
unsupportedList: []string{"1.23.1", addNPatchVersion(xdscommon.EnvoyVersions[0], 1)},
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{
|
|
|
|
isCompatible: false,
|
|
|
|
versionIncompatible: addNPatchVersion(xdscommon.EnvoyVersions[0], 1),
|
|
|
|
},
|
2022-12-20 17:58:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "error-bad-input",
|
|
|
|
envoyVersion: "1.abc.3",
|
2023-02-06 17:14:35 +00:00
|
|
|
unsupportedList: xdscommon.UnsupportedEnvoyVersions,
|
2023-03-03 18:29:34 +00:00
|
|
|
expectedCompat: envoyCompat{},
|
2022-12-20 17:58:19 +00:00
|
|
|
isErrorExpected: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tests {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
actual, err := checkEnvoyVersionCompatibility(tc.envoyVersion, tc.unsupportedList)
|
|
|
|
if tc.isErrorExpected {
|
|
|
|
assert.Error(t, err)
|
|
|
|
} else {
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2023-03-03 18:29:34 +00:00
|
|
|
assert.Equal(t, tc.expectedCompat, actual)
|
2022-12-20 17:58:19 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func addNPatchVersion(s string, n int) string {
|
|
|
|
splitS := strings.Split(s, ".")
|
|
|
|
minor, _ := strconv.Atoi(splitS[2])
|
|
|
|
minor += n
|
|
|
|
return fmt.Sprintf("%s.%s.%d", splitS[0], splitS[1], minor)
|
|
|
|
}
|
|
|
|
|
|
|
|
func addNMinorVersion(s string, n int) string {
|
|
|
|
splitS := strings.Split(s, ".")
|
|
|
|
major, _ := strconv.Atoi(splitS[1])
|
|
|
|
major += n
|
|
|
|
return fmt.Sprintf("%s.%d.%s", splitS[0], major, splitS[2])
|
|
|
|
}
|