Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
Signed-off-by: yangyang <[email protected]>
  • Loading branch information
yangyy93 committed Oct 10, 2023
1 parent 977adf0 commit 9d134ce
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion internal/provisioner/controller/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,8 @@ func TestGatewayReconcile(t *testing.T) {
},
Spec: contourv1alpha1.ContourDeploymentSpec{
Envoy: &contourv1alpha1.EnvoySettings{
BaseID: 1,
BaseID: 1,
OverloadMaxHeapSize: 10000000,
},
},
},
Expand All @@ -1127,6 +1128,56 @@ func TestGatewayReconcile(t *testing.T) {
},
},

"If ContourDeployment.Spec.Envoy.OverloadMaxHeapSize is specified, the envoy-initconfig container's arguments contain --overload-max-heap": {
gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller),
gatewayClassParams: &contourv1alpha1.ContourDeployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "projectcontour",
Name: "gatewayclass-1-params",
},
Spec: contourv1alpha1.ContourDeploymentSpec{
Envoy: &contourv1alpha1.EnvoySettings{
OverloadMaxHeapSize: 10000000,
},
},
},
gateway: makeGateway(),
assertions: func(t *testing.T, r *gatewayReconciler, gw *gatewayv1beta1.Gateway, reconcileErr error) {
ds := &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Namespace: "gateway-1",
Name: "envoy-gateway-1",
},
}
require.NoError(t, r.client.Get(context.Background(), keyFor(ds), ds))
assert.Contains(t, ds.Spec.Template.Spec.InitContainers[0].Args, "--overload-max-heap=10000000")
},
},

"If ContourDeployment.Spec.Envoy.OverloadMaxHeapSize is not specified, the envoy-initconfig container's arguments contain --overload-max-heap=0": {
gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller),
gatewayClassParams: &contourv1alpha1.ContourDeployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "projectcontour",
Name: "gatewayclass-1-params",
},
Spec: contourv1alpha1.ContourDeploymentSpec{
Envoy: &contourv1alpha1.EnvoySettings{},
},
},
gateway: makeGateway(),
assertions: func(t *testing.T, r *gatewayReconciler, gw *gatewayv1beta1.Gateway, reconcileErr error) {
ds := &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Namespace: "gateway-1",
Name: "envoy-gateway-1",
},
}
require.NoError(t, r.client.Get(context.Background(), keyFor(ds), ds))
assert.Contains(t, ds.Spec.Template.Spec.InitContainers[0].Args, "--overload-max-heap=0")
},
},

"If ContourDeployment.Spec.Contour.PodAnnotations is specified, the Contour pods' have annotations for prometheus & user-defined": {
gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller),
gatewayClassParams: &contourv1alpha1.ContourDeployment{
Expand Down

0 comments on commit 9d134ce

Please sign in to comment.