Skip to content
Open
Changes from all commits
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
33 changes: 33 additions & 0 deletions test/e2e/features/deployer/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ var (
"TestSelfManagedGateway": {
Manifests: []string{selfManagedGateway},
},
"TestGatewayParametersUpdateTriggersReconciliation": {
Manifests: []string{gatewayWithParameters},
},
}
)

Expand Down Expand Up @@ -320,6 +323,36 @@ func (s *testingSuite) TestSelfManagedGateway() {
)
}

func (s *testingSuite) TestGatewayParametersUpdateTriggersReconciliation() {
s.TestInstallation.AssertionsT(s.T()).EventuallyReadyReplicas(s.Ctx, proxyObjectMeta, gomega.Equal(1))

// Patch GatewayParameters to add a new pod annotation
s.patchGatewayParameters(gwParamsDefaultObjectMeta, func(parameters *kgateway.GatewayParameters) {
if parameters.Spec.Kube.PodTemplate == nil {
parameters.Spec.Kube.PodTemplate = &kgateway.Pod{}
}
if parameters.Spec.Kube.PodTemplate.ExtraAnnotations == nil {
parameters.Spec.Kube.PodTemplate.ExtraAnnotations = map[string]string{}
}
parameters.Spec.Kube.PodTemplate.ExtraAnnotations["test-reconcile-annotation"] = "updated"
})

// Verify that the deployment's pod template annotations are updated,
// which proves that the GatewayParameters change triggered reconciliation
s.TestInstallation.AssertionsT(s.T()).Gomega.Eventually(func(g gomega.Gomega) {
proxyDeployment := &appsv1.Deployment{}
err := s.TestInstallation.ClusterContext.Client.Get(s.Ctx, client.ObjectKey{
Namespace: proxyObjectMeta.Namespace,
Name: proxyObjectMeta.Name,
}, proxyDeployment)
g.Expect(err).NotTo(gomega.HaveOccurred())
g.Expect(proxyDeployment.Spec.Template.Annotations).To(
gomega.HaveKeyWithValue("test-reconcile-annotation", "updated"),
"pod template should have the annotation added via GatewayParameters patch",
)
}).WithTimeout(60 * time.Second).WithPolling(1 * time.Second).Should(gomega.Succeed())
}

// patchGateway accepts a reference to an object, and a patch function. It then queries the object,
// performs the patch in memory, and writes the object back to the cluster.
func (s *testingSuite) patchGateway(objectMeta metav1.ObjectMeta, patchFn func(*gwv1.Gateway)) {
Expand Down