From feda2e35bd9193b0fcc98fab54c8be615b994342 Mon Sep 17 00:00:00 2001 From: izturn <44051386+izturn@users.noreply.github.com> Date: Sat, 5 Aug 2023 02:07:22 +0800 Subject: [PATCH] simplify ut for dag (#5532) Signed-off-by: gang.liu --- internal/dag/accessors_test.go | 62 ++++------- internal/dag/builder_test.go | 184 +++++---------------------------- internal/dag/cache_test.go | 30 ++---- internal/dag/dag_test.go | 14 +-- internal/dag/status_test.go | 89 +++------------- 5 files changed, 69 insertions(+), 310 deletions(-) diff --git a/internal/dag/accessors_test.go b/internal/dag/accessors_test.go index 6f2bba51d1f..0a1104e6277 100644 --- a/internal/dag/accessors_test.go +++ b/internal/dag/accessors_test.go @@ -25,6 +25,18 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" ) +func makeServicePort(name string, protocol v1.Protocol, port int32, extras ...int) v1.ServicePort { + p := v1.ServicePort{ + Name: name, + Protocol: protocol, + Port: port, + } + if len(extras) != 0 { + p.TargetPort = intstr.FromInt(extras[0]) + } + return p + +} func TestBuilderLookupService(t *testing.T) { s1 := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -32,12 +44,7 @@ func TestBuilderLookupService(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -47,20 +54,7 @@ func TestBuilderLookupService(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{ - { - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }, - { - Name: "health", - Protocol: "TCP", - Port: 8998, - TargetPort: intstr.FromInt(8998), - }, - }, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080), makeServicePort("health", "TCP", 8998, 8998)}, }, } @@ -72,12 +66,7 @@ func TestBuilderLookupService(t *testing.T) { Spec: v1.ServiceSpec{ Type: v1.ServiceTypeExternalName, ExternalName: "external.projectcontour.io", - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(80), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 80, 80)}, }, } @@ -89,12 +78,7 @@ func TestBuilderLookupService(t *testing.T) { Spec: v1.ServiceSpec{ Type: v1.ServiceTypeExternalName, ExternalName: "localhost", - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(80), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 80, 80)}, }, } @@ -149,18 +133,8 @@ func TestBuilderLookupService(t *testing.T) { Weight: 1, ServiceName: "externalnamevalid", ServiceNamespace: "default", - ServicePort: v1.ServicePort{ - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(80), - }, - HealthPort: v1.ServicePort{ - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(80), - }, + ServicePort: makeServicePort("http", "TCP", 80, 80), + HealthPort: makeServicePort("http", "TCP", 80, 80), }, ExternalName: "external.projectcontour.io", }, diff --git a/internal/dag/builder_test.go b/internal/dag/builder_test.go index 78de3300116..cdfe40a2b01 100644 --- a/internal/dag/builder_test.go +++ b/internal/dag/builder_test.go @@ -42,12 +42,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Namespace: "projectcontour", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -57,12 +52,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Namespace: "projectcontour", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -72,12 +62,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Namespace: "projectcontour", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -87,12 +72,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Namespace: "custom", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -102,12 +82,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) { Namespace: "projectcontour", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 80, 8080)}, }, } @@ -6619,12 +6594,7 @@ func TestDAGInsert(t *testing.T) { }, }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(8888), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 80, 8888)}, }, } @@ -6665,12 +6635,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -6680,12 +6645,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "nginx-ingress", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8009, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8009, 8080)}, }, } @@ -7019,12 +6979,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7038,12 +6993,7 @@ func TestDAGInsert(t *testing.T) { }, }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7060,12 +7010,7 @@ func TestDAGInsert(t *testing.T) { }, }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7076,12 +7021,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7093,12 +7033,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7109,12 +7044,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 9999, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 9999, 8080)}, }, } @@ -7124,12 +7054,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "marketing", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7152,17 +7077,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "https", - Protocol: "TCP", - Port: 443, - TargetPort: intstr.FromInt(443), - }, { - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(80), - }}, + Ports: []v1.ServicePort{makeServicePort("https", "TCP", 443, 443), makeServicePort("http", "TCP", 80, 80)}, }, } @@ -7172,11 +7087,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "it", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "blog", - Protocol: "TCP", - Port: 8080, - }}, + Ports: []v1.ServicePort{makeServicePort("blog", "TCP", 8080)}, }, } @@ -7186,12 +7097,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "teama", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -7201,12 +7107,7 @@ func TestDAGInsert(t *testing.T) { Namespace: "teamb", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -14143,12 +14044,7 @@ func TestGatewayWithHTTPProxyAndIngress(t *testing.T) { Namespace: "projectcontour", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } sec1 := &v1.Secret{ @@ -15113,11 +15009,7 @@ func TestDAGRootNamespaces(t *testing.T) { Namespace: "allowed1", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080)}, }, } @@ -15127,11 +15019,7 @@ func TestDAGRootNamespaces(t *testing.T) { Namespace: "allowed2", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080)}, }, } @@ -15279,12 +15167,7 @@ func TestHTTPProxyConficts(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -15294,12 +15177,7 @@ func TestHTTPProxyConficts(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -15725,12 +15603,7 @@ func TestDefaultHeadersPolicies(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -15741,12 +15614,7 @@ func TestDefaultHeadersPolicies(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } diff --git a/internal/dag/cache_test.go b/internal/dag/cache_test.go index 1b256322b42..7dcb892a9ac 100644 --- a/internal/dag/cache_test.go +++ b/internal/dag/cache_test.go @@ -1779,14 +1779,6 @@ func TestLookupService(t *testing.T) { } } - port := func(name string, port int32, protocol v1.Protocol) v1.ServicePort { - return v1.ServicePort{ - Name: name, - Port: port, - Protocol: protocol, - } - } - tests := map[string]struct { cache *KubernetesCache meta types.NamespacedName @@ -1796,40 +1788,40 @@ func TestLookupService(t *testing.T) { wantErr error }{ "service and port exist with valid service protocol, lookup by port num": { - cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))), + cache: cache(service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80))), meta: types.NamespacedName{Namespace: "default", Name: "service-1"}, port: intstr.FromInt(80), - wantSvc: service("default", "service-1", port("http", 80, v1.ProtocolTCP)), - wantPort: port("http", 80, v1.ProtocolTCP), + wantSvc: service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80)), + wantPort: makeServicePort("http", v1.ProtocolTCP, 80), }, "service and port exist with valid service protocol, lookup by port name": { - cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))), + cache: cache(service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80))), meta: types.NamespacedName{Namespace: "default", Name: "service-1"}, port: intstr.FromString("http"), - wantSvc: service("default", "service-1", port("http", 80, v1.ProtocolTCP)), - wantPort: port("http", 80, v1.ProtocolTCP), + wantSvc: service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80)), + wantPort: makeServicePort("http", v1.ProtocolTCP, 80), }, "service and port exist with valid service protocol, lookup by wrong port num": { - cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))), + cache: cache(service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80))), meta: types.NamespacedName{Namespace: "default", Name: "service-1"}, port: intstr.FromInt(9999), wantErr: errors.New(`port "9999" on service "default/service-1" not matched`), }, "service and port exist with valid service protocol, lookup by wrong port name": { - cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))), + cache: cache(service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80))), meta: types.NamespacedName{Namespace: "default", Name: "service-1"}, port: intstr.FromString("wrong-port-name"), wantErr: errors.New(`port "wrong-port-name" on service "default/service-1" not matched`), }, "service and port exist, invalid service protocol": { - cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolUDP))), + cache: cache(service("default", "service-1", makeServicePort("http", v1.ProtocolUDP, 80))), meta: types.NamespacedName{Namespace: "default", Name: "service-1"}, port: intstr.FromString("http"), - wantSvc: service("default", "service-1", port("http", 80, v1.ProtocolTCP)), + wantSvc: service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80)), wantErr: errors.New(`unsupported service protocol "UDP"`), }, "service does not exist": { - cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))), + cache: cache(service("default", "service-1", makeServicePort("http", v1.ProtocolTCP, 80))), meta: types.NamespacedName{Namespace: "default", Name: "nonexistent-service"}, port: intstr.FromInt(80), wantErr: errors.New(`service "default/nonexistent-service" not found`), diff --git a/internal/dag/dag_test.go b/internal/dag/dag_test.go index 50b3bfc56c2..a7ee4def4b9 100644 --- a/internal/dag/dag_test.go +++ b/internal/dag/dag_test.go @@ -122,12 +122,7 @@ func TestServiceClusterValid(t *testing.T) { } func TestServiceClusterAdd(t *testing.T) { - port := v1.ServicePort{ - Name: "foo", - Protocol: v1.ProtocolTCP, - Port: 32, - } - + port := makeServicePort("foo", "TCP", 32) s := ServiceCluster{ ClusterName: "test", } @@ -165,12 +160,7 @@ func TestServiceClusterAdd(t *testing.T) { } func TestServiceClusterRebalance(t *testing.T) { - port := v1.ServicePort{ - Name: "foo", - Protocol: v1.ProtocolTCP, - Port: 32, - } - + port := makeServicePort("foo", "TCP", 32) cases := map[string]struct { have ServiceCluster want ServiceCluster diff --git a/internal/dag/status_test.go b/internal/dag/status_test.go index 37c12c09306..54b8577cbad 100644 --- a/internal/dag/status_test.go +++ b/internal/dag/status_test.go @@ -472,17 +472,7 @@ func TestDAGStatus(t *testing.T) { Namespace: "roots", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "https", - Protocol: "TCP", - Port: 443, - TargetPort: intstr.FromInt(443), - }, { - Name: "http", - Protocol: "TCP", - Port: 80, - TargetPort: intstr.FromInt(80), - }}, + Ports: []v1.ServicePort{makeServicePort("https", "TCP", 443, 443), makeServicePort("http", "TCP", 80, 80)}, }, } @@ -4727,12 +4717,7 @@ func TestDAGStatus(t *testing.T) { Namespace: "roots", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, }, &contour_api_v1.HTTPProxy{ @@ -4804,12 +4789,7 @@ func TestDAGStatus(t *testing.T) { Namespace: "roots", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, }, &contour_api_v1.HTTPProxy{ @@ -5253,12 +5233,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -5268,12 +5243,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -5283,12 +5253,7 @@ func TestGatewayAPIHTTPRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -9481,12 +9446,7 @@ func TestGatewayAPITLSRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -10113,12 +10073,7 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -10128,12 +10083,7 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -10143,12 +10093,7 @@ func TestGatewayAPIGRPCRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -11003,12 +10948,7 @@ func TestGatewayAPITCPRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, } @@ -11018,12 +10958,7 @@ func TestGatewayAPITCPRouteDAGStatus(t *testing.T) { Namespace: "default", }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{ - Name: "http", - Protocol: "TCP", - Port: 8080, - TargetPort: intstr.FromInt(8080), - }}, + Ports: []v1.ServicePort{makeServicePort("http", "TCP", 8080, 8080)}, }, }