|
4 | 4 | "testing"
|
5 | 5 |
|
6 | 6 | "github.com/stretchr/testify/assert"
|
| 7 | + corev1 "k8s.io/api/core/v1" |
| 8 | + "k8s.io/apimachinery/pkg/util/intstr" |
7 | 9 | "k8s.io/utils/ptr"
|
8 | 10 |
|
9 | 11 | gw2_v1alpha1 "github.com/kgateway-dev/kgateway/v2/api/v1alpha1"
|
@@ -227,6 +229,92 @@ func TestDeepMergeGatewayParameters(t *testing.T) {
|
227 | 229 | assert.Equal(t, expectedMap, got.Spec.Kube.ServiceAccount.ExtraAnnotations)
|
228 | 230 | },
|
229 | 231 | },
|
| 232 | + { |
| 233 | + name: "should have only one probeHandler action", |
| 234 | + dst: &gw2_v1alpha1.GatewayParameters{ |
| 235 | + Spec: gw2_v1alpha1.GatewayParametersSpec{ |
| 236 | + Kube: &gw2_v1alpha1.KubernetesProxyConfig{ |
| 237 | + PodTemplate: &gw2_v1alpha1.Pod{ |
| 238 | + StartupProbe: &corev1.Probe{ |
| 239 | + ProbeHandler: corev1.ProbeHandler{ |
| 240 | + Exec: &corev1.ExecAction{ |
| 241 | + Command: []string{"exec", "command"}, |
| 242 | + }, |
| 243 | + }, |
| 244 | + }, |
| 245 | + }, |
| 246 | + }, |
| 247 | + }, |
| 248 | + }, |
| 249 | + src: &gw2_v1alpha1.GatewayParameters{ |
| 250 | + Spec: gw2_v1alpha1.GatewayParametersSpec{ |
| 251 | + Kube: &gw2_v1alpha1.KubernetesProxyConfig{ |
| 252 | + PodTemplate: &gw2_v1alpha1.Pod{ |
| 253 | + StartupProbe: &corev1.Probe{ |
| 254 | + ProbeHandler: corev1.ProbeHandler{ |
| 255 | + TCPSocket: &corev1.TCPSocketAction{ |
| 256 | + Port: intstr.FromString("8080"), |
| 257 | + }, |
| 258 | + }, |
| 259 | + }, |
| 260 | + }, |
| 261 | + }, |
| 262 | + }, |
| 263 | + }, |
| 264 | + want: &gw2_v1alpha1.GatewayParameters{ |
| 265 | + Spec: gw2_v1alpha1.GatewayParametersSpec{ |
| 266 | + Kube: &gw2_v1alpha1.KubernetesProxyConfig{ |
| 267 | + PodTemplate: &gw2_v1alpha1.Pod{ |
| 268 | + StartupProbe: &corev1.Probe{ |
| 269 | + ProbeHandler: corev1.ProbeHandler{ |
| 270 | + TCPSocket: &corev1.TCPSocketAction{ |
| 271 | + Port: intstr.FromString("8080"), |
| 272 | + }, |
| 273 | + }, |
| 274 | + }, |
| 275 | + }, |
| 276 | + }, |
| 277 | + }, |
| 278 | + }, |
| 279 | + }, |
| 280 | + { |
| 281 | + name: "should merge the default probeHandler action if none specified", |
| 282 | + dst: &gw2_v1alpha1.GatewayParameters{ |
| 283 | + Spec: gw2_v1alpha1.GatewayParametersSpec{ |
| 284 | + Kube: &gw2_v1alpha1.KubernetesProxyConfig{ |
| 285 | + PodTemplate: &gw2_v1alpha1.Pod{ |
| 286 | + StartupProbe: &corev1.Probe{ |
| 287 | + ProbeHandler: corev1.ProbeHandler{ |
| 288 | + Exec: &corev1.ExecAction{ |
| 289 | + Command: []string{"exec", "command"}, |
| 290 | + }, |
| 291 | + }, |
| 292 | + }, |
| 293 | + }, |
| 294 | + }, |
| 295 | + }, |
| 296 | + }, |
| 297 | + src: &gw2_v1alpha1.GatewayParameters{ |
| 298 | + Spec: gw2_v1alpha1.GatewayParametersSpec{ |
| 299 | + Kube: &gw2_v1alpha1.KubernetesProxyConfig{}, |
| 300 | + }, |
| 301 | + }, |
| 302 | + want: &gw2_v1alpha1.GatewayParameters{ |
| 303 | + Spec: gw2_v1alpha1.GatewayParametersSpec{ |
| 304 | + Kube: &gw2_v1alpha1.KubernetesProxyConfig{ |
| 305 | + PodTemplate: &gw2_v1alpha1.Pod{ |
| 306 | + StartupProbe: &corev1.Probe{ |
| 307 | + ProbeHandler: corev1.ProbeHandler{ |
| 308 | + Exec: &corev1.ExecAction{ |
| 309 | + Command: []string{"exec", "command"}, |
| 310 | + }, |
| 311 | + }, |
| 312 | + }, |
| 313 | + }, |
| 314 | + }, |
| 315 | + }, |
| 316 | + }, |
| 317 | + }, |
230 | 318 | }
|
231 | 319 |
|
232 | 320 | for _, tt := range tests {
|
|
0 commit comments