Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more EnvoyProxy cases #2120

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
36 changes: 26 additions & 10 deletions test/cel-validation/envoyproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestEnvoyProxyProvider(t *testing.T) {
wantErrors: []string{"allocateLoadBalancerNodePorts can only be set for LoadBalancer type"},
},
{
desc: "loadBalancerIP-pass-case1",
desc: "ServiceTypeLoadBalancer-with-valid-IP",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Expand All @@ -139,14 +139,14 @@ func TestEnvoyProxyProvider(t *testing.T) {
wantErrors: []string{},
},
{
desc: "loadBalancerIP-pass-case2",
desc: "ServiceTypeLoadBalancer-with-empty-IP",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyService: &egv1a1.KubernetesServiceSpec{
Type: ptr.To(egv1a1.ServiceTypeClusterIP),
Type: ptr.To(egv1a1.ServiceTypeLoadBalancer),
},
},
},
Expand All @@ -155,38 +155,54 @@ func TestEnvoyProxyProvider(t *testing.T) {
wantErrors: []string{},
},
{
desc: "loadBalancerIP-fail-case1",
desc: "ServiceTypeLoadBalancer-with-invalid-IP",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyService: &egv1a1.KubernetesServiceSpec{
Type: ptr.To(egv1a1.ServiceTypeClusterIP),
Type: ptr.To(egv1a1.ServiceTypeLoadBalancer),
LoadBalancerIP: ptr.To("a.b.c.d"),
},
},
},
}
},
wantErrors: []string{"loadBalancerIP can only be set for LoadBalancer type"},
wantErrors: []string{"loadBalancerIP must be a valid IPv4 address"},
},
{
desc: "loadBalancerIP-fail-case2",
desc: "ServiceTypeClusterIP-with-empty-IP",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyService: &egv1a1.KubernetesServiceSpec{
Type: ptr.To(egv1a1.ServiceTypeLoadBalancer),
LoadBalancerIP: ptr.To("a.b.c.d"),
Type: ptr.To(egv1a1.ServiceTypeClusterIP),
},
},
},
}
},
wantErrors: []string{"loadBalancerIP must be a valid IPv4 address"},
wantErrors: []string{},
},
{
desc: "ServiceTypeClusterIP-with-LoadBalancerIP",
mutate: func(envoy *egv1a1.EnvoyProxy) {
envoy.Spec = egv1a1.EnvoyProxySpec{
Provider: &egv1a1.EnvoyProxyProvider{
Type: egv1a1.ProviderTypeKubernetes,
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyService: &egv1a1.KubernetesServiceSpec{
Type: ptr.To(egv1a1.ServiceTypeClusterIP),
LoadBalancerIP: ptr.To("20.205.243.166"), // github ip for test only
},
},
},
}
},
wantErrors: []string{"loadBalancerIP can only be set for LoadBalancer type"},
},
}

Expand Down