-
Notifications
You must be signed in to change notification settings - Fork 592
/
gateway_conformance_test.go
126 lines (110 loc) · 5.03 KB
/
gateway_conformance_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//go:build conformance_tests
package conformance
import (
"fmt"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
"github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/gateway"
testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/util/test"
"github.com/kong/kubernetes-ingress-controller/v2/test/consts"
)
const (
showDebug = true
shouldCleanup = true
enableAllSupportedFeatures = true
)
var conformanceTestsBaseManifests = fmt.Sprintf("%s/conformance/base/manifests.yaml", consts.GatewayRawRepoURL)
func TestGatewayConformance(t *testing.T) {
t.Log("configuring environment for gateway conformance tests")
client, err := client.New(env.Cluster().Config(), client.Options{})
require.NoError(t, err)
require.NoError(t, gatewayv1alpha2.AddToScheme(client.Scheme()))
require.NoError(t, gatewayv1beta1.AddToScheme(client.Scheme()))
t.Log("starting the controller manager")
args := []string{
fmt.Sprintf("--ingress-class=%s", ingressClass),
fmt.Sprintf("--admission-webhook-cert=%s", testutils.KongSystemServiceCert),
fmt.Sprintf("--admission-webhook-key=%s", testutils.KongSystemServiceKey),
fmt.Sprintf("--admission-webhook-listen=%s:%d", testutils.AdmissionWebhookListenHost, testutils.AdmissionWebhookListenPort),
"--profiling",
"--dump-config",
"--log-level=trace",
"--debug-log-reduce-redundancy",
fmt.Sprintf("--feature-gates=%s", consts.DefaultFeatureGates),
"--anonymous-reports=false",
}
require.NoError(t, testutils.DeployControllerManagerForCluster(ctx, globalDeprecatedLogger, globalLogger, env.Cluster(), args...))
t.Log("creating GatewayClass for gateway conformance tests")
gatewayClass := &gatewayv1beta1.GatewayClass{
ObjectMeta: metav1.ObjectMeta{
Name: uuid.NewString(),
Annotations: map[string]string{
annotations.GatewayClassUnmanagedAnnotation: annotations.GatewayClassUnmanagedAnnotationValuePlaceholder,
},
},
Spec: gatewayv1beta1.GatewayClassSpec{
ControllerName: gateway.GetControllerName(),
},
}
require.NoError(t, client.Create(ctx, gatewayClass))
t.Cleanup(func() { assert.NoError(t, client.Delete(ctx, gatewayClass)) })
exemptFeatures := sets.New(suite.SupportMesh)
t.Log("starting the gateway conformance test suite")
cSuite := suite.New(suite.Options{
Client: client,
GatewayClassName: gatewayClass.Name,
Debug: showDebug,
CleanupBaseResources: shouldCleanup,
EnableAllSupportedFeatures: enableAllSupportedFeatures,
ExemptFeatures: exemptFeatures,
BaseManifests: conformanceTestsBaseManifests,
SkipTests: []string{
// standard conformance
tests.HTTPRouteHeaderMatching.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/4166
// requires an 8080 listener, which our manually-built test gateway does not have
tests.HTTPRouteRedirectPortAndScheme.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/4164
// only 10 and 11 broken, but no way to omit individual cases
tests.HTTPRouteMethodMatching.ShortName,
// extended conformance
// https://github.com/Kong/kubernetes-ingress-controller/issues/3680
tests.GatewayClassObservedGenerationBump.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3678
tests.TLSRouteSimpleSameNamespace.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3679
tests.HTTPRouteQueryParamMatching.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3681
tests.HTTPRouteRedirectPort.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3682
tests.HTTPRouteRedirectScheme.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3683
tests.HTTPRouteResponseHeaderModifier.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/4165
tests.HTTPRouteRequestMirror.ShortName,
// experimental conformance
// https://github.com/Kong/kubernetes-ingress-controller/issues/3684
tests.HTTPRouteRedirectPath.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3685
tests.HTTPRouteRewriteHost.ShortName,
// https://github.com/Kong/kubernetes-ingress-controller/issues/3686
tests.HTTPRouteRewritePath.ShortName,
},
})
cSuite.Setup(t)
// To work with individual tests only, you can disable the normal Run call and construct a slice containing a
// single test only, e.g.:
//
//cSuite.Run(t, []suite.ConformanceTest{tests.HTTPRouteRedirectPortAndScheme})
cSuite.Run(t, tests.ConformanceTests)
}