Skip to content

Commit

Permalink
tests: fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodman10 committed Aug 14, 2023
1 parent 8d15c3f commit 80e9419
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 126 deletions.
112 changes: 0 additions & 112 deletions internal/dataplane/parser/translate_failures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
knative "knative.dev/networking/pkg/apis/networking/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/failures"
"github.com/kong/kubernetes-ingress-controller/v2/internal/store"
kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
)

// This file contains unit test functions to test translation failures genreated by parser.
Expand Down Expand Up @@ -54,116 +52,6 @@ func TestTranslationFailureUnsupportedObjectsExpressionRoutes(t *testing.T) {
},
},
},
{
name: "TCPIngresses and UDPIngresses are not supported",
objects: store.FakeObjects{
TCPIngresses: []*kongv1beta1.TCPIngress{
{
TypeMeta: metav1.TypeMeta{
Kind: "TCPIngress",
APIVersion: kongv1beta1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "tcpingress-1",
Namespace: "default",
Annotations: map[string]string{
annotations.IngressClassKey: annotations.DefaultIngressClass,
},
},
},
},
UDPIngresses: []*kongv1beta1.UDPIngress{
{
TypeMeta: metav1.TypeMeta{
Kind: "UDPIngress",
APIVersion: kongv1beta1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "udpingress-1",
Namespace: "default",
Annotations: map[string]string{
annotations.IngressClassKey: annotations.DefaultIngressClass,
},
},
},
},
},
causingObjects: []client.Object{
&kongv1beta1.TCPIngress{
ObjectMeta: metav1.ObjectMeta{
Name: "tcpingress-1",
Namespace: "default",
},
},
&kongv1beta1.UDPIngress{
ObjectMeta: metav1.ObjectMeta{
Name: "udpingress-1",
Namespace: "default",
},
},
},
},
{
name: "TCPRoutes, UDPRoutes and TLSRoutes in gateway APIs are not supported",
objects: store.FakeObjects{
TCPRoutes: []*gatewayv1alpha2.TCPRoute{
{
TypeMeta: metav1.TypeMeta{
Kind: "TCPRoute",
APIVersion: gatewayv1alpha2.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "tcproute-1",
Namespace: "default",
},
},
},
UDPRoutes: []*gatewayv1alpha2.UDPRoute{
{
TypeMeta: metav1.TypeMeta{
Kind: "UDPRoute",
APIVersion: gatewayv1alpha2.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "udproute-1",
Namespace: "default",
},
},
},
TLSRoutes: []*gatewayv1alpha2.TLSRoute{
{
TypeMeta: metav1.TypeMeta{
Kind: "TLSRoute",
APIVersion: gatewayv1alpha2.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "tlsroute-1",
Namespace: "default",
},
},
},
},
causingObjects: []client.Object{
&gatewayv1alpha2.TCPRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "tcproute-1",
Namespace: "default",
},
},
&gatewayv1alpha2.UDPRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "udproute-1",
Namespace: "default",
},
},
&gatewayv1alpha2.TLSRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "tlsroute-1",
Namespace: "default",
},
},
},
},
}

for _, tc := range testCases {
Expand Down
28 changes: 14 additions & 14 deletions internal/dataplane/parser/translate_kong_l4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ func TestFromTCPIngressV1beta1(t *testing.T) {
func TestIngressRulesFromTCPIngressV1beta1UsingExpressionRoutes(t *testing.T) {
testCases := []struct {
name string
tcpIngresses []*configurationv1beta1.TCPIngress
tcpIngresses []*kongv1beta1.TCPIngress
expectedKongServices []kongstate.Service
expectedKongRoutes map[string][]kongstate.Route
expectedFailures []failures.ResourceFailure
}{
{
name: "tcpingress with single rule",
tcpIngresses: []*configurationv1beta1.TCPIngress{
tcpIngresses: []*kongv1beta1.TCPIngress{
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Expand All @@ -233,11 +233,11 @@ func TestIngressRulesFromTCPIngressV1beta1UsingExpressionRoutes(t *testing.T) {
annotations.IngressClassKey: annotations.DefaultIngressClass,
},
},
Spec: configurationv1beta1.TCPIngressSpec{
Rules: []configurationv1beta1.IngressRule{
Spec: kongv1beta1.TCPIngressSpec{
Rules: []kongv1beta1.IngressRule{
{
Port: 9000,
Backend: configurationv1beta1.IngressBackend{
Backend: kongv1beta1.IngressBackend{
ServiceName: "foo-svc",
ServicePort: 80,
},
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestIngressRulesFromTCPIngressV1beta1UsingExpressionRoutes(t *testing.T) {
},
{
name: "tcpingress with multiple rules",
tcpIngresses: []*configurationv1beta1.TCPIngress{
tcpIngresses: []*kongv1beta1.TCPIngress{
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Expand All @@ -283,18 +283,18 @@ func TestIngressRulesFromTCPIngressV1beta1UsingExpressionRoutes(t *testing.T) {
annotations.IngressClassKey: annotations.DefaultIngressClass,
},
},
Spec: configurationv1beta1.TCPIngressSpec{
Rules: []configurationv1beta1.IngressRule{
Spec: kongv1beta1.TCPIngressSpec{
Rules: []kongv1beta1.IngressRule{
{
Port: 9000,
Backend: configurationv1beta1.IngressBackend{
Backend: kongv1beta1.IngressBackend{
ServiceName: "foo-svc1",
ServicePort: 80,
},
},
{
Port: 9090,
Backend: configurationv1beta1.IngressBackend{
Backend: kongv1beta1.IngressBackend{
ServiceName: "foo-svc2",
ServicePort: 8080,
},
Expand Down Expand Up @@ -352,7 +352,7 @@ func TestIngressRulesFromTCPIngressV1beta1UsingExpressionRoutes(t *testing.T) {
},
{
name: "tcpingress with sni",
tcpIngresses: []*configurationv1beta1.TCPIngress{
tcpIngresses: []*kongv1beta1.TCPIngress{
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Expand All @@ -361,12 +361,12 @@ func TestIngressRulesFromTCPIngressV1beta1UsingExpressionRoutes(t *testing.T) {
annotations.IngressClassKey: annotations.DefaultIngressClass,
},
},
Spec: configurationv1beta1.TCPIngressSpec{
Rules: []configurationv1beta1.IngressRule{
Spec: kongv1beta1.TCPIngressSpec{
Rules: []kongv1beta1.IngressRule{
{
Host: "www.foo-bar.com",
Port: 9000,
Backend: configurationv1beta1.IngressBackend{
Backend: kongv1beta1.IngressBackend{
ServiceName: "foo-svc",
ServicePort: 80,
},
Expand Down

0 comments on commit 80e9419

Please sign in to comment.