From 1d0f1ca1a6b27a135b4369d3d2f8f750e8200235 Mon Sep 17 00:00:00 2001 From: Patryk Strugacz Date: Tue, 10 Dec 2024 14:10:54 +0100 Subject: [PATCH] Add missing fields, add tests --- api/v1alpha2/istio_merge.go | 6 ++ api/v1alpha2/merge_test.go | 3 + .../configuration-suite/configuration.feature | 5 ++ tests/integration/scenario.go | 70 +++++++++---------- .../integration/steps/istio_cr_template.yaml | 17 +++++ 5 files changed, 66 insertions(+), 35 deletions(-) diff --git a/api/v1alpha2/istio_merge.go b/api/v1alpha2/istio_merge.go index de80e9aa2..4ada42344 100644 --- a/api/v1alpha2/istio_merge.go +++ b/api/v1alpha2/istio_merge.go @@ -251,6 +251,12 @@ func (i *Istio) mergeResources(op iopv1alpha1.IstioOperator) (iopv1alpha1.IstioO return op, err } } + if i.Spec.Components.EgressGateway.Enabled != nil { + if op.Spec.Components.EgressGateways[0].Enabled == nil { + op.Spec.Components.EgressGateways[0].Enabled = &wrapperspb.BoolValue{} + } + op.Spec.Components.EgressGateways[0].Enabled.Value = *i.Spec.Components.EgressGateway.Enabled + } } if i.Spec.Components.Pilot != nil { diff --git a/api/v1alpha2/merge_test.go b/api/v1alpha2/merge_test.go index cf799a72d..b88887c9c 100644 --- a/api/v1alpha2/merge_test.go +++ b/api/v1alpha2/merge_test.go @@ -598,6 +598,9 @@ var _ = Describe("Merge", func() { iopMemoryRequests := out.Spec.Components.EgressGateways[0].K8S.Resources.Requests["memory"] Expect(iopMemoryRequests).To(Equal(memoryRequests)) + + iopEnabled := out.Spec.Components.EgressGateways[0].Enabled.GetValue() + Expect(iopEnabled).To(Equal(enabled)) }) }) }) diff --git a/tests/integration/features/configuration-suite/configuration.feature b/tests/integration/features/configuration-suite/configuration.feature index 3bd9e164e..62a2598b6 100644 --- a/tests/integration/features/configuration-suite/configuration.feature +++ b/tests/integration/features/configuration-suite/configuration.feature @@ -44,6 +44,11 @@ Feature: Configuration of Istio module And Istio CR "istio-sample" in namespace "kyma-system" has status "Ready" Then Request with header "X-Forwarded-For" with value "10.2.1.1,10.0.0.1" sent to httpbin should return "X-Envoy-External-Address" with value "10.2.1.1" + Scenario: Egress Gateway has correct configuration + When Template value "EgressGatewayEnabled" is set to "true" + And Istio CR "istio-sample" from "istio_cr_template" is updated in namespace "kyma-system" + Then Istio CR "istio-sample" in namespace "kyma-system" has status "Ready" + Scenario: External authorizer When Template value "Namespace" is set to "default" And Istio CR "istio-sample" from "istio_cr_ext_authz_template" is applied in namespace "kyma-system" diff --git a/tests/integration/scenario.go b/tests/integration/scenario.go index 54769cc9b..0744dfba9 100644 --- a/tests/integration/scenario.go +++ b/tests/integration/scenario.go @@ -10,50 +10,50 @@ func initScenario(ctx *godog.ScenarioContext) { ctx.After(istioCrTearDown) t := steps.TemplatedIstioCr{} - ctx.Step(`^Evaluated cluster size is "([^"]*)"$`, steps.EvaluatedClusterSizeIs) - ctx.Step(`^Istio CRD is installed$`, steps.IstioCRDIsInstalled) - ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" has status "([^"]*)"$`, steps.IstioCRInNamespaceHasStatus) - ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" has condition with reason "([^"]*)" of type "([^"]*)" and status "([^"]*)"$`, steps.IstioCRInNamespaceHasStatusCondition) - ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" has description "([^"]*)"$`, steps.IstioCRInNamespaceHasDescription) - ctx.Step(`^Template value "([^"]*)" is set to "([^"]*)"$`, t.SetTemplateValue) - ctx.Step(`^Istio CR "([^"]*)" from "([^"]*)" is applied in namespace "([^"]*)"$`, t.IstioCRIsAppliedInNamespace) - ctx.Step(`^Istio CR "([^"]*)" from "([^"]*)" is updated in namespace "([^"]*)"$`, t.IstioCRIsUpdatedInNamespace) - ctx.Step(`^Namespace "([^"]*)" is "([^"]*)"$`, steps.NamespaceIsPresent) - ctx.Step(`^Namespace "([^"]*)" is created$`, steps.NamespaceIsCreated) - ctx.Step(`^Namespace "([^"]*)" has "([^"]*)" label and "([^"]*)" annotation`, steps.NamespaceHasLabelAndAnnotation) - ctx.Step(`^Istio CRDs "([^"]*)" be present on cluster$`, steps.IstioCRDsBePresentOnCluster) - ctx.Step(`^"([^"]*)" has "([^"]*)" set to cpu - "([^"]*)" and memory - "([^"]*)"$`, steps.IstioComponentHasResourcesSetToCpuAndMemory) - ctx.Step(`^Pod of deployment "([^"]*)" in namespace "([^"]*)" has container "([^"]*)" with resource "([^"]*)" set to cpu - "([^"]*)" and memory - "([^"]*)"$`, steps.DeploymentHasPodWithContainerResourcesSetToCpuAndMemory) + ctx.Step(`^"([^"]*)" "([^"]*)" in namespace "([^"]*)" is "([^"]*)"`, steps.ResourceIsPresent) ctx.Step(`^"([^"]*)" "([^"]*)" in namespace "([^"]*)" is deleted$`, steps.ResourceInNamespaceIsDeleted) + ctx.Step(`^"([^"]*)" "([^"]*)" in namespace "([^"]*)" is ready$`, steps.ResourceIsReady) ctx.Step(`^"([^"]*)" "([^"]*)" is deleted$`, steps.ClusterResourceIsDeleted) + ctx.Step(`^"([^"]*)" has "([^"]*)" set to cpu - "([^"]*)" and memory - "([^"]*)"$`, steps.IstioComponentHasResourcesSetToCpuAndMemory) ctx.Step(`^"([^"]*)" is not present on cluster$`, steps.ResourceNotPresent) - ctx.Step(`^Istio injection is "([^"]*)" in namespace "([^"]*)"$`, steps.SetIstioInjection) + ctx.Step(`^Access logging is enabled for the mesh using "([^"]*)" provider$`, steps.EnableAccessLogging) ctx.Step(`^Application "([^"]*)" in namespace "([^"]*)" has proxy with "([^"]*)" set to cpu - "([^"]*)" and memory - "([^"]*)"$`, steps.ApplicationHasProxyResourcesSetToCpuAndMemory) + ctx.Step(`^Application "([^"]*)" in namespace "([^"]*)" has required version of proxy$`, steps.ApplicationPodShouldHaveIstioProxyInRequiredVersion) ctx.Step(`^Application pod "([^"]*)" in namespace "([^"]*)" has Istio proxy "([^"]*)"$`, steps.ApplicationPodShouldHaveIstioProxy) + ctx.Step(`^Authorization policy "([^"]*)" in namespace "([^"]*)" with app selector "([^"]*)" is using extension provider "([^"]*)" for operation "([^"]*)"$`, steps.CreateAuthorizationPolicyExtAuthz) + ctx.Step(`^Container "([^"]*)" of "([^"]*)" "([^"]*)" in namespace "([^"]*)" has required version$`, steps.IstioResourceContainerHasRequiredVersion) ctx.Step(`^Destination rule "([^"]*)" in namespace "([^"]*)" with host "([^"]*)" exists$`, steps.CreateDestinationRule) - ctx.Step(`^Istio is manually uninstalled$`, steps.UninstallIstio) - ctx.Step(`^Httpbin application "([^"]*)" deployment is created in namespace "([^"]*)"$`, steps.CreateHttpbinApplication) + ctx.Step(`^Evaluated cluster size is "([^"]*)"$`, steps.EvaluatedClusterSizeIs) + ctx.Step(`^Ext-authz application "([^"]*)" deployment is created in namespace "([^"]*)"$`, steps.CreateExtAuthzApplication) ctx.Step(`^Httpbin application "([^"]*)" deployment is created in namespace "([^"]*)" with service port "([^"]*)"$`, steps.CreateHttpbinApplicationWithServicePort) - ctx.Step(`^Nginx application "([^"]*)" deployment is created in namespace "([^"]*)" with forward to "([^"]*)" and service port 80$`, steps.CreateNginxApplication) + ctx.Step(`^Httpbin application "([^"]*)" deployment is created in namespace "([^"]*)"$`, steps.CreateHttpbinApplication) + ctx.Step(`^Istio CR "([^"]*)" from "([^"]*)" is applied in namespace "([^"]*)"$`, t.IstioCRIsAppliedInNamespace) + ctx.Step(`^Istio CR "([^"]*)" from "([^"]*)" is updated in namespace "([^"]*)"$`, t.IstioCRIsUpdatedInNamespace) + ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" has condition with reason "([^"]*)" of type "([^"]*)" and status "([^"]*)"$`, steps.IstioCRInNamespaceHasStatusCondition) + ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" has description "([^"]*)"$`, steps.IstioCRInNamespaceHasDescription) + ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" has status "([^"]*)"$`, steps.IstioCRInNamespaceHasStatus) + ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" status update happened in the last 20 seconds$`, steps.IstioCrStatusUpdateHappened) + ctx.Step(`^Istio CRD is installed$`, steps.IstioCRDIsInstalled) + ctx.Step(`^Istio CRDs "([^"]*)" be present on cluster$`, steps.IstioCRDsBePresentOnCluster) + ctx.Step(`^Istio controller has been upgraded$`, steps.DeployIstioOperator) ctx.Step(`^Istio gateway "([^"]*)" is configured in namespace "([^"]*)"$`, steps.CreateIstioGateway) - ctx.Step(`^Virtual service "([^"]*)" exposing service "([^"]*)" by gateway "([^"]*)" is configured in namespace "([^"]*)"$`, steps.CreateVirtualService) - ctx.Step(`^Virtual service "([^"]*)" exposing service "([^"]*)" with port "([^"]*)" by gateway "([^"]*)" is configured in namespace "([^"]*)"$`, steps.CreateVirtualServiceWithPort) - ctx.Step(`^Request with header "([^"]*)" with value "([^"]*)" sent to httpbin should return "([^"]*)" with value "([^"]*)"$`, steps.ValidateHeader) - ctx.Step(`^Request to path "([^"]*)" should return "([^"]*)" with value "([^"]*)" in body$`, steps.ValidateHeaderInBody) + ctx.Step(`^Istio injection is "([^"]*)" in namespace "([^"]*)"$`, steps.SetIstioInjection) + ctx.Step(`^Istio is manually uninstalled$`, steps.UninstallIstio) + ctx.Step(`^Log of container "([^"]*)" in deployment "([^"]*)" in namespace "([^"]*)" contains "([^"]*)"$`, steps.ContainerLogContainsString) + ctx.Step(`^Namespace "([^"]*)" has "([^"]*)" label and "([^"]*)" annotation`, steps.NamespaceHasLabelAndAnnotation) + ctx.Step(`^Namespace "([^"]*)" is "([^"]*)"$`, steps.NamespaceIsPresent) + ctx.Step(`^Namespace "([^"]*)" is created$`, steps.NamespaceIsCreated) + ctx.Step(`^Nginx application "([^"]*)" deployment is created in namespace "([^"]*)" with forward to "([^"]*)" and service port 80$`, steps.CreateNginxApplication) + ctx.Step(`^OTEL Collector mock "([^"]*)" deployment is created in namespace "([^"]*)"$`, steps.CreateTelemetryCollectorMock) + ctx.Step(`^Pod of deployment "([^"]*)" in namespace "([^"]*)" has container "([^"]*)" with resource "([^"]*)" set to cpu - "([^"]*)" and memory - "([^"]*)"$`, steps.DeploymentHasPodWithContainerResourcesSetToCpuAndMemory) + ctx.Step(`^Request sent to exposed httpbin, should contain public client IP in "([^"]*)" header$`, steps.ValidatePublicClientIpInHeader) ctx.Step(`^Request to path "([^"]*)" should have response code "([^"]*)"$`, steps.ValidateResponseStatusCode) + ctx.Step(`^Request to path "([^"]*)" should return "([^"]*)" with value "([^"]*)" in body$`, steps.ValidateHeaderInBody) + ctx.Step(`^Request with header "([^"]*)" with value "([^"]*)" sent to httpbin should return "([^"]*)" with value "([^"]*)"$`, steps.ValidateHeader) ctx.Step(`^Request with header "([^"]*)" with value "([^"]*)" to path "([^"]*)" should have response code "([^"]*)"$`, steps.ValidateResponseCodeForRequestWithHeader) - ctx.Step(`^"([^"]*)" "([^"]*)" in namespace "([^"]*)" is "([^"]*)"`, steps.ResourceIsPresent) - ctx.Step(`^Request sent to exposed httpbin, should contain public client IP in "([^"]*)" header$`, steps.ValidatePublicClientIpInHeader) - ctx.Step(`^Access logging is enabled for the mesh using "([^"]*)" provider$`, steps.EnableAccessLogging) - ctx.Step(`^Log of container "([^"]*)" in deployment "([^"]*)" in namespace "([^"]*)" contains "([^"]*)"$`, steps.ContainerLogContainsString) - ctx.Step(`^Tracing is enabled for the mesh using provider "([^"]*)"$`, steps.EnableTracing) ctx.Step(`^Service is created for the otel collector "([^"]*)" in namespace "([^"]*)"$`, steps.CreateOpenTelemetryService) - ctx.Step(`^OTEL Collector mock "([^"]*)" deployment is created in namespace "([^"]*)"$`, steps.CreateTelemetryCollectorMock) - ctx.Step(`^Ext-authz application "([^"]*)" deployment is created in namespace "([^"]*)"$`, steps.CreateExtAuthzApplication) - ctx.Step(`^Authorization policy "([^"]*)" in namespace "([^"]*)" with app selector "([^"]*)" is using extension provider "([^"]*)" for operation "([^"]*)"$`, steps.CreateAuthorizationPolicyExtAuthz) - ctx.Step(`^"([^"]*)" "([^"]*)" in namespace "([^"]*)" is ready$`, steps.ResourceIsReady) - ctx.Step(`^Istio CR "([^"]*)" in namespace "([^"]*)" status update happened in the last 20 seconds$`, steps.IstioCrStatusUpdateHappened) - ctx.Step(`^Istio controller has been upgraded$`, steps.DeployIstioOperator) - ctx.Step(`^Application "([^"]*)" in namespace "([^"]*)" has required version of proxy$`, steps.ApplicationPodShouldHaveIstioProxyInRequiredVersion) - ctx.Step(`^Container "([^"]*)" of "([^"]*)" "([^"]*)" in namespace "([^"]*)" has required version$`, steps.IstioResourceContainerHasRequiredVersion) + ctx.Step(`^Template value "([^"]*)" is set to "([^"]*)"$`, t.SetTemplateValue) + ctx.Step(`^Tracing is enabled for the mesh using provider "([^"]*)"$`, steps.EnableTracing) + ctx.Step(`^Virtual service "([^"]*)" exposing service "([^"]*)" by gateway "([^"]*)" is configured in namespace "([^"]*)"$`, steps.CreateVirtualService) + ctx.Step(`^Virtual service "([^"]*)" exposing service "([^"]*)" with port "([^"]*)" by gateway "([^"]*)" is configured in namespace "([^"]*)"$`, steps.CreateVirtualServiceWithPort) } diff --git a/tests/integration/steps/istio_cr_template.yaml b/tests/integration/steps/istio_cr_template.yaml index bf437c095..9e2023055 100644 --- a/tests/integration/steps/istio_cr_template.yaml +++ b/tests/integration/steps/istio_cr_template.yaml @@ -38,6 +38,23 @@ spec: hpaSpec: maxReplicas: {{.IGMaxReplicas}} minReplicas: {{.IGMinReplicas}} + egressGateway: + enabled: {{.EgressGatewayEnabled}} + k8s: + resources: + limits: + cpu: {{.EGCPULimit}} + memory: {{.EGMemoryLimit}} + requests: + cpu: {{.EGCPURequests}} + memory: {{.EGMemoryRequests}} + strategy: + rollingUpdate: + maxSurge: {{.EGMaxSurge}} + maxUnavailable: {{.EGMaxUnavailable}} + hpaSpec: + maxReplicas: {{.EGMaxReplicas}} + minReplicas: {{.EGMinReplicas}} proxy: k8s: resources: