1
- //go:build ignore
2
-
3
1
package deployer
4
2
5
3
import (
6
4
"context"
7
5
"fmt"
8
6
"time"
9
7
10
- tlsv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
11
8
"github.com/onsi/gomega"
12
9
"github.com/onsi/gomega/gstruct"
13
10
"github.com/stretchr/testify/assert"
@@ -20,10 +17,8 @@ import (
20
17
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
21
18
22
19
"github.com/kgateway-dev/kgateway/v2/api/v1alpha1"
23
- "github.com/kgateway-dev/kgateway/v2/internal/gloo/pkg/utils"
24
20
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/wellknown"
25
21
"github.com/kgateway-dev/kgateway/v2/pkg/utils/envoyutils/admincli"
26
- "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils"
27
22
"github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e"
28
23
testdefaults "github.com/kgateway-dev/kgateway/v2/test/kubernetes/e2e/defaults"
29
24
)
@@ -38,7 +33,7 @@ type testingSuite struct {
38
33
ctx context.Context
39
34
40
35
// testInstallation contains all the metadata/utilities necessary to execute a series of tests
41
- // against an installation of Gloo Gateway
36
+ // against an installation of kgateway
42
37
testInstallation * e2e.TestInstallation
43
38
44
39
// manifests maps test name to a list of manifests to apply before the test
@@ -77,10 +72,6 @@ func (s *testingSuite) SetupSuite() {
77
72
"TestSelfManagedGateway" : {
78
73
selfManagedGateway ,
79
74
},
80
- "TestConfigureAwsLambda" : {
81
- testdefaults .NginxPodManifest ,
82
- gatewayWithoutParameters ,
83
- },
84
75
}
85
76
s .manifestObjects = map [string ][]client.Object {
86
77
testdefaults .NginxPodManifest : {testdefaults .NginxPod , testdefaults .NginxSvc },
@@ -111,6 +102,14 @@ func (s *testingSuite) AfterTest(suiteName, testName string) {
111
102
s .Require ().NoError (err )
112
103
s .testInstallation .Assertions .EventuallyObjectsNotExist (s .ctx , s .manifestObjects [manifest ]... )
113
104
}
105
+
106
+ // make sure the proxy pods are gone before the next test starts
107
+ s .testInstallation .Assertions .EventuallyPodsNotExist (
108
+ s .ctx ,
109
+ s .testInstallation .Metadata .InstallNamespace ,
110
+ metav1.ListOptions {
111
+ LabelSelector : "app.kubernetes.io/name=gw" ,
112
+ })
114
113
}
115
114
116
115
func (s * testingSuite ) TestProvisionDeploymentAndService () {
@@ -123,7 +122,7 @@ func (s *testingSuite) TestConfigureProxiesFromGatewayParameters() {
123
122
// check that the labels and annotations got passed through from GatewayParameters to the ServiceAccount
124
123
sa := & corev1.ServiceAccount {}
125
124
err := s .testInstallation .ClusterContext .Client .Get (s .ctx ,
126
- types.NamespacedName {Name : glooProxyObjectMeta .Name , Namespace : glooProxyObjectMeta .Namespace },
125
+ types.NamespacedName {Name : proxyObjectMeta .Name , Namespace : proxyObjectMeta .Namespace },
127
126
sa )
128
127
s .Require ().NoError (err )
129
128
s .testInstallation .Assertions .Gomega .Expect (sa .GetLabels ()).To (
@@ -134,7 +133,7 @@ func (s *testingSuite) TestConfigureProxiesFromGatewayParameters() {
134
133
// check that the labels and annotations got passed through from GatewayParameters to the Service
135
134
svc := & corev1.Service {}
136
135
err = s .testInstallation .ClusterContext .Client .Get (s .ctx ,
137
- types.NamespacedName {Name : glooProxyObjectMeta .Name , Namespace : glooProxyObjectMeta .Namespace },
136
+ types.NamespacedName {Name : proxyObjectMeta .Name , Namespace : proxyObjectMeta .Namespace },
138
137
svc )
139
138
s .Require ().NoError (err )
140
139
s .testInstallation .Assertions .Gomega .Expect (svc .GetLabels ()).To (
@@ -155,22 +154,12 @@ func (s *testingSuite) TestConfigureProxiesFromGatewayParameters() {
155
154
156
155
s .testInstallation .Assertions .AssertEnvoyAdminApi (
157
156
s .ctx ,
158
- proxyDeployment . ObjectMeta ,
157
+ proxyObjectMeta ,
159
158
serverInfoLogLevelAssertion (s .testInstallation , "debug" , "connection:trace,upstream:debug" ),
160
159
xdsClusterAssertion (s .testInstallation ),
161
160
)
162
161
}
163
162
164
- func (s * testingSuite ) TestConfigureAwsLambda () {
165
- s .testInstallation .Assertions .EventuallyReadyReplicas (s .ctx , proxyDeployment .ObjectMeta , gomega .Equal (1 ))
166
-
167
- s .testInstallation .Assertions .AssertEnvoyAdminApi (
168
- s .ctx ,
169
- proxyDeployment .ObjectMeta ,
170
- awsStsClusterAssertion (s .testInstallation ),
171
- )
172
- }
173
-
174
163
func (s * testingSuite ) TestProvisionResourcesUpdatedWithValidParameters () {
175
164
s .testInstallation .Assertions .EventuallyReadyReplicas (s .ctx , proxyDeployment .ObjectMeta , gomega .Equal (1 ))
176
165
@@ -224,14 +213,13 @@ func (s *testingSuite) TestProvisionResourcesNotUpdatedWithInvalidParameters() {
224
213
g .Expect (proxyDeployment .Spec .Template .Spec .Containers [0 ].SecurityContext .Privileged ).To (origPrivileged )
225
214
g .Expect (proxyDeployment .Spec .Replicas ).To (gstruct .PointTo (gomega .Equal (int32 (1 ))))
226
215
}, "30s" , "1s" ).Should (gomega .Succeed ())
227
-
228
216
}
229
217
230
218
func (s * testingSuite ) TestSelfManagedGateway () {
231
219
s .Require ().EventuallyWithT (func (c * assert.CollectT ) {
232
220
gw := & gwv1.Gateway {}
233
221
err := s .testInstallation .ClusterContext .Client .Get (s .ctx ,
234
- types.NamespacedName {Name : glooProxyObjectMeta .Name , Namespace : glooProxyObjectMeta .Namespace },
222
+ types.NamespacedName {Name : proxyObjectMeta .Name , Namespace : proxyObjectMeta .Namespace },
235
223
gw )
236
224
assert .NoError (c , err , "gateway not found" )
237
225
@@ -314,59 +302,12 @@ func xdsClusterAssertion(testInstallation *e2e.TestInstallation) func(ctx contex
314
302
xdsSocketAddress := xdsCluster .GetLoadAssignment ().GetEndpoints ()[0 ].GetLbEndpoints ()[0 ].GetEndpoint ().GetAddress ().GetSocketAddress ()
315
303
g .Expect (xdsSocketAddress ).NotTo (gomega .BeNil ())
316
304
317
- g .Expect (xdsSocketAddress .GetAddress ()).To (gomega .Equal (kubeutils .ServiceFQDN (metav1.ObjectMeta {
318
- Name : "kgateway" ,
319
- Namespace : testInstallation .Metadata .InstallNamespace ,
320
- })), "xds socket address points to gloo service, in installation namespace" )
321
-
322
- g .Expect (xdsSocketAddress .GetPortValue ()).To (gomega .Equal (9977 ), "xds socket port points to gloo service, in installation namespace" )
323
- }).
324
- WithContext (ctx ).
325
- WithTimeout (time .Second * 10 ).
326
- WithPolling (time .Millisecond * 200 ).
327
- Should (gomega .Succeed ())
328
- }
329
- }
330
-
331
- // awsStsClusterAssertion asserts that:
332
- // - if the installation is configured to use aws with service account creds, then the proxy contains an aws sts cluster with the expected sts uri
333
- // - if the installation is NOT configured to use aws with service account creds, then no aws sts cluster should exist on the proxy
334
- func awsStsClusterAssertion (testInstallation * e2e.TestInstallation ) func (ctx context.Context , adminClient * admincli.Client ) {
335
- // get aws values from installation
336
- awsOpts := testInstallation .Metadata .AwsOptions
337
- shouldHaveStsCluster := awsOpts != nil && awsOpts .EnableServiceAccountCredentials
338
- var expectedStsUri string
339
- if shouldHaveStsCluster {
340
- expectedStsUri = fmt .Sprintf ("sts.%s.amazonaws.com" , awsOpts .StsCredentialsRegion )
341
- }
342
-
343
- return func (ctx context.Context , adminClient * admincli.Client ) {
344
- testInstallation .Assertions .Gomega .Eventually (func (g gomega.Gomega ) {
345
- clusters , err := adminClient .GetStaticClusters (ctx )
346
- g .Expect (err ).NotTo (gomega .HaveOccurred (), "can get static clusters from config dump" )
347
-
348
- awsStsCluster , ok := clusters ["aws_sts_cluster" ]
349
- if shouldHaveStsCluster {
350
- g .Expect (ok ).To (gomega .BeTrue (), "should contain cluster aws_sts_cluster" )
351
- } else {
352
- g .Expect (ok ).To (gomega .BeFalse (), "should not contain cluster aws_sts_cluster" )
353
- // nothing else to test, so return here
354
- return
355
- }
305
+ g .Expect (xdsSocketAddress .GetAddress ()).To (gomega .Equal (
306
+ fmt .Sprintf ("%s.%s.svc.cluster.local" , wellknown .DefaultXdsService , testInstallation .Metadata .InstallNamespace ),
307
+ ), "xds socket address points to kgateway service, in installation namespace" )
356
308
357
- // check that transport socket has expected values
358
- msg , err := utils .AnyToMessage (awsStsCluster .GetTransportSocket ().GetTypedConfig ())
359
- g .Expect (err ).NotTo (gomega .HaveOccurred ())
360
- tlsCtx , ok := msg .(* tlsv3.UpstreamTlsContext )
361
- g .Expect (ok ).To (gomega .BeTrue (), "should be able to get UpstreamTlsContext" )
362
- g .Expect (tlsCtx .GetSni ()).To (gomega .Equal (expectedStsUri ))
363
-
364
- // check that load assignment has expected values
365
- g .Expect (awsStsCluster .GetLoadAssignment ().GetEndpoints ()).To (gomega .HaveLen (1 ))
366
- g .Expect (awsStsCluster .GetLoadAssignment ().GetEndpoints ()[0 ].GetLbEndpoints ()).To (gomega .HaveLen (1 ))
367
- socketAddr := awsStsCluster .GetLoadAssignment ().GetEndpoints ()[0 ].GetLbEndpoints ()[0 ].GetEndpoint ().GetAddress ().GetSocketAddress ()
368
- g .Expect (socketAddr ).NotTo (gomega .BeNil ())
369
- g .Expect (socketAddr .GetAddress ()).To (gomega .Equal (expectedStsUri ))
309
+ g .Expect (xdsSocketAddress .GetPortValue ()).To (gomega .Equal (wellknown .DefaultXdsPort ),
310
+ "xds socket port points to kgateway service, in installation namespace" )
370
311
}).
371
312
WithContext (ctx ).
372
313
WithTimeout (time .Second * 10 ).
0 commit comments