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

e2e: fix EnvoyGatewayBackend/TLSRouteBackendIP test not working on IPv6 first cluster #4727

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 0 additions & 12 deletions test/e2e/testdata/httproute-to-backend-ip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
spec:
selector:
app: infra-backend-v1
clusterIP: 10.96.96.96
ports:
- protocol: TCP
port: 8080
Expand Down Expand Up @@ -34,14 +33,3 @@ spec:
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-ip
namespace: gateway-conformance-infra
spec:
endpoints:
- ip:
address: 10.96.96.96
port: 8080
12 changes: 0 additions & 12 deletions test/e2e/testdata/tlsroute-to-backend-ip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ spec:
kind: Backend
name: backend-ip
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-ip
namespace: gateway-conformance-infra
spec:
endpoints:
- ip:
address: 10.96.96.96
port: 443
---
apiVersion: v1
kind: Service
metadata:
Expand All @@ -34,7 +23,6 @@ metadata:
spec:
selector:
app: tls-backend-2
clusterIP: 10.96.96.96
ports:
- protocol: TCP
port: 443
Expand Down
22 changes: 20 additions & 2 deletions test/e2e/tests/httproute_with_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
}

var EnvoyGatewayBackendTest = suite.ConformanceTest{
ShortName: "EnvoyGatewayBackendTest",
ShortName: "EnvoyGatewayBackend",
Description: "Routes with a backend ref to a backend",
Manifests: []string{
"testdata/httproute-to-backend-fqdn.yaml",
Expand Down Expand Up @@ -51,11 +51,29 @@ var EnvoyGatewayBackendTest = suite.ConformanceTest{
})

t.Run("of type IP", func(t *testing.T) {
svcNN := types.NamespacedName{
Name: "infra-backend-v1-clusterip",
Namespace: "gateway-conformance-infra",
}
svc, err := GetService(suite.Client, svcNN)
if err != nil {
t.Fatalf("failed to get service %s: %v", svcNN, err)
}

backendIPName := "backend-ip"
ns := "gateway-conformance-infra"
err = CreateBackend(suite.Client, types.NamespacedName{Name: backendIPName, Namespace: ns}, svc.Spec.ClusterIP)
if err != nil {
t.Fatalf("failed to create backend %s: %v", backendIPName, err)
}
if err != nil {
t.Fatalf("failed to create backend %s: %v", backendIPName, err)
}

routeNN := types.NamespacedName{Name: "httproute-to-backend-ip", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "backend-ip", Namespace: ns})
BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: backendIPName, Namespace: ns})

expectedResponse := http.ExpectedResponse{
Request: http.Request{
Expand Down
19 changes: 17 additions & 2 deletions test/e2e/tests/tlsroute_with_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,29 @@ var TLSRouteBackendFQDNTest = suite.ConformanceTest{
}

var TLSRouteBackendIPTest = suite.ConformanceTest{
ShortName: "TLSRouteBackendIPTest",
ShortName: "TLSRouteBackendIP",
Description: "TLSRoutes with a backend ref to a Backend",
Manifests: []string{
"testdata/tlsroute-to-backend-ip.yaml",
},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
t.Run("TLSRoute with a IP type Backend", func(t *testing.T) {
testTLSRouteWithBackend(t, suite, "tlsroute-to-backend-ip", "backend-ip")
svcNN := types.NamespacedName{
Name: "tls-backend-2-clusterip",
Namespace: "gateway-conformance-infra",
}
svc, err := GetService(suite.Client, svcNN)
if err != nil {
t.Fatalf("failed to get service %s: %v", svcNN, err)
}

backendIPName := "backend-ip"
ns := "gateway-conformance-infra"
err = CreateBackend(suite.Client, types.NamespacedName{Name: backendIPName, Namespace: ns}, svc.Spec.ClusterIP)
if err != nil {
t.Fatalf("failed to create backend %s: %v", backendIPName, err)
}
testTLSRouteWithBackend(t, suite, "tlsroute-to-backend-ip", backendIPName)
})
},
}
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,31 @@ func CollectAndDump(t *testing.T, rest *rest.Config) {
tlog.Logf(t, "\ndata: \n%s", data)
}
}

func GetService(c client.Client, nn types.NamespacedName) (*corev1.Service, error) {
svc := &corev1.Service{}
if err := c.Get(context.Background(), nn, svc); err != nil {
return nil, err
}
return svc, nil
}

func CreateBackend(c client.Client, nn types.NamespacedName, clusterIP string) error {
backend := &egv1a1.Backend{
ObjectMeta: metav1.ObjectMeta{
Namespace: nn.Namespace,
Name: nn.Name,
},
Spec: egv1a1.BackendSpec{
Endpoints: []egv1a1.BackendEndpoint{
{
IP: &egv1a1.IPEndpoint{
Address: clusterIP,
Port: 8080,
},
},
},
},
}
return c.Create(context.TODO(), backend)
}
Loading