tcp stream (und damit: tls passthrough) ist implementiert
This commit is contained in:
1 parent
6a5cb95f92
commit
fdcd06c93f
16 files changed
+1008
-75
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sultan/pkg/license"
|
||||
)
|
||||
|
||||
func caWorkload(extra map[string]string) Workload {
|
||||
labels := map[string]string{
|
||||
"traefik.enable": "true",
|
||||
"traefik.tcp.routers.ca.rule": "HostSNI(`ca.lab.kunde.de`)",
|
||||
"traefik.tcp.routers.ca.tls.passthrough": "true",
|
||||
"traefik.tcp.services.ca.loadbalancer.server.port": "9000",
|
||||
}
|
||||
for k, v := range extra {
|
||||
labels[k] = v
|
||||
}
|
||||
return Workload{Name: "ca_passthrough_test", Host: "100.64.0.1", Labels: labels}
|
||||
}
|
||||
|
||||
// TLS-Passthrough kommt mit Feature tcp_stream neben HTTP-Routen in die
|
||||
// Ausgabe; ohne Feature wird nur der TCP-Router verworfen.
|
||||
func TestRegistry_TCPPassthrough(t *testing.T) {
|
||||
r, dir, a := newRegistry()
|
||||
r.Update(ctx, "n1", NodeState{Workloads: []Workload{wp("wordpress", "100.64.0.1", "kunde.de"), caWorkload(nil)}})
|
||||
if c := r.Config(); c.TCP != nil || len(routers(r)) != 1 {
|
||||
t.Fatalf("ohne Feature: %+v", c.TCP)
|
||||
}
|
||||
if e := a.entries(); len(e) != 1 || e[0].Router != "ca" {
|
||||
t.Errorf("Audit = %+v", e)
|
||||
}
|
||||
|
||||
dir.set("n1", func(nc *NodeContext) { nc.License.Features = []license.Feature{license.FeatureTCPStream} })
|
||||
r.Refresh(ctx)
|
||||
c := r.Config()
|
||||
if c.TCP == nil || c.TCP.Routers["kunde__n1__ca"] == nil || len(routers(r)) != 1 {
|
||||
t.Fatalf("mit Feature: %+v", c.TCP)
|
||||
}
|
||||
if addr := c.TCP.Services["kunde__n1__ca"].LoadBalancer.Servers[0].Address; addr != "100.64.0.1:9000" {
|
||||
t.Errorf("Adresse = %q", addr)
|
||||
}
|
||||
}
|
||||
|
||||
// sultan.maintenance an einem TCP-Dienst entfernt dessen Route.
|
||||
func TestRegistry_TCPServiceMaintenanceLabel(t *testing.T) {
|
||||
r, dir, _ := newRegistry()
|
||||
dir.set("n1", func(nc *NodeContext) { nc.License.Features = []license.Feature{license.FeatureTCPStream} })
|
||||
r.Update(ctx, "n1", NodeState{Workloads: []Workload{caWorkload(map[string]string{"sultan.maintenance": "true"})}})
|
||||
if c := r.Config(); c.TCP != nil {
|
||||
t.Errorf("Route trotz Wartung: %+v", c.TCP)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user