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

NET-9173: tcp acceptance tests #3988

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions acceptance/framework/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ func RunCommand(t testutil.TestingTB, options *k8s.KubectlOptions, command Comma

go func() {
output, err := exec.Command(command.Command, command.Args...).CombinedOutput()
for _, v := range command.Args {
if strings.Contains(v, "-vvvsSf") {
fmt.Printf("%s%s\n", command.Command, command.Args)
fmt.Println(string(output))
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for testing, will remove

resultCh <- &cmdResult{output: string(output), err: err}
}()

Expand Down
1 change: 1 addition & 0 deletions acceptance/framework/k8s/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func CheckStaticServerConnectionFailing(t *testing.T, options *k8s.KubectlOption
"curl: (52) Empty reply from server",
"curl: (7) Failed to connect",
"curl: (56) Recv failure: Connection reset by peer",
"curl: (35) OpenSSL SSL_connect: Connection reset by peer",
}, "", curlArgs...)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: v1
kind: ConfigMap
metadata:
name: static-server-config
data:
config: |
{
local_certs
skip_install_trust
auto_https disable_redirects
}
static-server-hostname.virtual.server.consul {
log
respond "hello world"
}
:80 {
log
respond "hello world"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: static-server
spec:
replicas: 1
selector:
matchLabels:
app: static-server
template:
metadata:
labels:
app: static-server
spec:
containers:
- name: caddy
image: caddy:latest
ports:
- name: https-port
containerPort: 443
- name: http-port
containerPort: 80
volumeMounts:
- name: data
mountPath: "/data"
- name: config
mountPath: /etc/caddy/
readOnly: true
serviceAccountName: static-server
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: static-server-config
items:
- key: "config"
path: "Caddyfile"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

resources:
- deployment.yaml
- configmap.yaml
- service.yaml
- serviceaccount.yaml
- psp-rolebinding.yaml
- privileged-scc-rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: static-server-openshift-privileged
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:openshift:scc:privileged
subjects:
- kind: ServiceAccount
name: static-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: static-server
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: test-psp
subjects:
- kind: ServiceAccount
name: static-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: v1
kind: Service
metadata:
name: static-server
labels:
app: static-server
spec:
ports:
- name: https-port
port: 443
targetPort: https-port
protocol: TCP
- name: http-port
port: 80
targetPort: http-port
protocol: TCP
selector:
app: static-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: v1
kind: ServiceAccount
metadata:
name: static-server
26 changes: 19 additions & 7 deletions acceptance/tests/peering/peering_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ func TestPeering_Connect(t *testing.T) {
t.Skipf("skipping this test because peering is not supported in version %v", cfg.ConsulVersion.String())
}

const staticServerPeer = "server"
const staticClientPeer = "client"
const (
staticServerPeer = "server"
staticClientPeer = "client"
)

cases := []struct {
name string
ACLsEnabled bool
}{
{
"default installation",
false,
},
// {
// "default installation",
// false,
// },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for testing

{
"secure installation",
true,
Expand Down Expand Up @@ -337,7 +339,7 @@ func TestPeering_Connect(t *testing.T) {

// Create the external server in the server Kubernetes cluster, outside the mesh in the "external" namespace
logger.Log(t, "creating static-server deployment in server peer outside of mesh")
k8s.DeployKustomize(t, externalServerOpts, cfg.NoCleanupOnFailure, cfg.NoCleanup, cfg.DebugDirectory, "../fixtures/bases/static-server")
k8s.DeployKustomize(t, externalServerOpts, cfg.NoCleanupOnFailure, cfg.NoCleanup, cfg.DebugDirectory, "../fixtures/bases/static-server-test-tcp")

// Prevent dialing the server directly through the sidecar.
terminatinggateway.CreateMeshConfigEntry(t, staticServerPeerClient, "")
Expand Down Expand Up @@ -377,6 +379,16 @@ func TestPeering_Connect(t *testing.T) {
// Test that we can make a call to the terminating gateway.
logger.Log(t, "trying calls to terminating gateway")
k8s.CheckStaticServerConnectionSuccessful(t, staticClientOpts, staticClientName, externalServerHostnameURL)

// Update the service default declaring the external service (aka Destination)
logger.Log(t, "updating service defaults to try tcp scenario")
// Register the external service.
externalServerHostnameURL = fmt.Sprintf("https://%s.virtual.%s.consul", externalServerHostnameID, staticServerPeer)

terminatinggateway.CreateServiceDefaultDestination(t, staticServerPeerClient, "", externalServerHostnameID, "", 443, fmt.Sprintf("%s.%s", externalServerServiceName, externalServerK8sNamespace))

logger.Log(t, "trying calls to terminating gateway")
k8s.CheckStaticServerConnectionSuccessful(t, staticClientOpts, staticClientName, "-k", externalServerHostnameURL)
}
})
}
Expand Down
Loading