diff --git a/pkg/testutils/moduletemplate.go b/pkg/testutils/moduletemplate.go index 28e7d9a587e..7f6e6ee91c8 100644 --- a/pkg/testutils/moduletemplate.go +++ b/pkg/testutils/moduletemplate.go @@ -17,13 +17,14 @@ func GetModuleTemplate(ctx context.Context, clnt client.Client, module v1beta2.Module, defaultChannel string, + namespace string, ) (*v1beta2.ModuleTemplate, error) { descriptorProvider := provider.NewCachedDescriptorProvider() templateLookup := templatelookup.NewTemplateLookup(clnt, descriptorProvider) availableModule := templatelookup.AvailableModule{ Module: module, } - templateInfo := templateLookup.PopulateModuleTemplateInfo(ctx, availableModule, ControlPlaneNamespace, + templateInfo := templateLookup.PopulateModuleTemplateInfo(ctx, availableModule, namespace, defaultChannel) if templateInfo.Err != nil { @@ -36,8 +37,9 @@ func ModuleTemplateExists(ctx context.Context, clnt client.Client, module v1beta2.Module, defaultChannel string, + namespace string, ) error { - moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, defaultChannel) + moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, defaultChannel, namespace) if moduleTemplate == nil || errors.Is(err, templatelookup.ErrNoTemplatesInListResult) { return ErrNotFound } @@ -47,7 +49,7 @@ func ModuleTemplateExists(ctx context.Context, func AllModuleTemplatesExists(ctx context.Context, clnt client.Client, kyma *v1beta2.Kyma) error { for _, module := range kyma.Spec.Modules { - if err := ModuleTemplateExists(ctx, clnt, module, kyma.Spec.Channel); err != nil { + if err := ModuleTemplateExists(ctx, clnt, module, kyma.Spec.Channel, kyma.Namespace); err != nil { return err } } @@ -61,8 +63,9 @@ func UpdateModuleTemplateSpec(ctx context.Context, key, newValue, kymaChannel string, + namespace string, ) error { - moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, kymaChannel) + moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, kymaChannel, namespace) if err != nil { return err } @@ -77,9 +80,9 @@ func UpdateModuleTemplateSpec(ctx context.Context, } func DeleteModuleTemplate(ctx context.Context, - clnt client.Client, module v1beta2.Module, kymaChannel string, + clnt client.Client, module v1beta2.Module, kymaChannel string, namespace string, ) error { - moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, kymaChannel) + moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, kymaChannel, namespace) if util.IsNotFound(err) { return nil } @@ -92,9 +95,9 @@ func DeleteModuleTemplate(ctx context.Context, } func ReadModuleVersionFromModuleTemplate(ctx context.Context, clnt client.Client, module v1beta2.Module, - channel string, + channel string, namespace string, ) (string, error) { - moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, channel) + moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, channel, namespace) if err != nil { return "", fmt.Errorf("failed to fetch ModuleTemplate: %w", err) } diff --git a/tests/e2e/module_deletion_test.go b/tests/e2e/module_deletion_test.go index 1f5c69c729b..9afd6bfc886 100644 --- a/tests/e2e/module_deletion_test.go +++ b/tests/e2e/module_deletion_test.go @@ -278,7 +278,7 @@ var _ = Describe("Non Blocking Kyma Module Deletion", Ordered, func() { It("Then ModuleTemplate is no longer in SKR Cluster", func() { Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(skrClient, module, kyma.Spec.Channel). + WithArguments(skrClient, module, kyma.Spec.Channel, RemoteNamespace). Should(Equal(ErrNotFound)) }) }) diff --git a/tests/e2e/module_upgrade_new_version_test.go b/tests/e2e/module_upgrade_new_version_test.go index f8100c2a4fc..a3715b087da 100644 --- a/tests/e2e/module_upgrade_new_version_test.go +++ b/tests/e2e/module_upgrade_new_version_test.go @@ -84,7 +84,7 @@ var _ = Describe("Module Upgrade By New Version", Ordered, func() { By("And Kyma Module Version in Kyma Status is updated") newModuleTemplateVersion, err := ReadModuleVersionFromModuleTemplate(ctx, kcpClient, module, - kyma.Spec.Channel) + kyma.Spec.Channel, ControlPlaneNamespace) Expect(err).ToNot(HaveOccurred()) Eventually(ModuleVersionInKymaStatusIsCorrect). diff --git a/tests/e2e/modulereleasemeta_sync_test.go b/tests/e2e/modulereleasemeta_sync_test.go index 524bf27ade0..888caaab62d 100644 --- a/tests/e2e/modulereleasemeta_sync_test.go +++ b/tests/e2e/modulereleasemeta_sync_test.go @@ -20,13 +20,13 @@ var _ = Describe("ModuleReleaseMeta Sync", Ordered, func() { By("Then the Template Operator v1 ModuleTemplate exists in the KCP Cluster") Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(kcpClient, module, v1beta2.DefaultChannel). + WithArguments(kcpClient, module, v1beta2.DefaultChannel, ControlPlaneNamespace). Should(Succeed()) By("And the Template Operator v1 ModuleTemplate exists in the SKR Cluster") Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(skrClient, module, v1beta2.DefaultChannel). + WithArguments(skrClient, module, v1beta2.DefaultChannel, RemoteNamespace). Should(Succeed()) By("And the ModuleReleaseMeta exists on the KCP Cluster with the correct channel-version") @@ -55,19 +55,19 @@ var _ = Describe("ModuleReleaseMeta Sync", Ordered, func() { It("When Template Operator v1 ModuleTemplate is removed from the KCP Cluster", func() { Eventually(DeleteModuleTemplate). WithContext(ctx). - WithArguments(kcpClient, module, v1beta2.DefaultChannel). + WithArguments(kcpClient, module, v1beta2.DefaultChannel, ControlPlaneNamespace). Should(Succeed()) By("Then Template Operator v1 ModuleTemplate no longer exists on the KCP Cluster") Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(kcpClient, module, v1beta2.DefaultChannel). + WithArguments(kcpClient, module, v1beta2.DefaultChannel, ControlPlaneNamespace). Should(Equal(ErrNotFound)) By("Then Template Operator v1 ModuleTemplate no longer exists on the SKR Cluster") Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(skrClient, module, v1beta2.DefaultChannel). + WithArguments(skrClient, module, v1beta2.DefaultChannel, RemoteNamespace). Should(Equal(ErrNotFound)) }) @@ -82,13 +82,13 @@ var _ = Describe("ModuleReleaseMeta Sync", Ordered, func() { By("Then the Template Operator v2 ModuleTemplate exists in the KCP Cluster") Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(kcpClient, module, v1beta2.DefaultChannel). + WithArguments(kcpClient, module, v1beta2.DefaultChannel, ControlPlaneNamespace). Should(Succeed()) By("And the Template Operator v2 ModuleTemplate exists in the SKR Cluster") Eventually(ModuleTemplateExists). WithContext(ctx). - WithArguments(skrClient, module, v1beta2.DefaultChannel). + WithArguments(skrClient, module, v1beta2.DefaultChannel, RemoteNamespace). Should(Succeed()) By("And the ModuleReleaseMeta exists on the KCP Cluster with the correct channel-version") diff --git a/tests/integration/controller/kcp/helper_test.go b/tests/integration/controller/kcp/helper_test.go index 058a369070f..d085d7ebeec 100644 --- a/tests/integration/controller/kcp/helper_test.go +++ b/tests/integration/controller/kcp/helper_test.go @@ -110,8 +110,9 @@ func expectModuleTemplateSpecGetReset( clnt client.Client, module v1beta2.Module, kymaChannel string, + namespace string, ) error { - moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, kymaChannel) + moduleTemplate, err := GetModuleTemplate(ctx, clnt, module, kymaChannel, namespace) if err != nil { return err } diff --git a/tests/integration/controller/kcp/remote_sync_test.go b/tests/integration/controller/kcp/remote_sync_test.go index 9bdc033b7fd..2aaf474718e 100644 --- a/tests/integration/controller/kcp/remote_sync_test.go +++ b/tests/integration/controller/kcp/remote_sync_test.go @@ -92,11 +92,11 @@ var _ = Describe("Kyma sync into Remote Cluster", Ordered, func() { Should(Succeed()) By("ModuleTemplate exists in KCP cluster") Eventually(ModuleTemplateExists, Timeout, Interval). - WithArguments(ctx, kcpClient, moduleInKCP, kyma.Spec.Channel). + WithArguments(ctx, kcpClient, moduleInKCP, kyma.Spec.Channel, ControlPlaneNamespace). Should(Succeed()) By("ModuleTemplate exists in SKR cluster") Eventually(ModuleTemplateExists, Timeout, Interval).WithArguments(ctx, skrClient, moduleInKCP, - kyma.Spec.Channel).Should(Succeed()) + kyma.Spec.Channel, RemoteNamespace).Should(Succeed()) By("No module synced to remote Kyma") Eventually(NotContainsModuleInSpec, Timeout, Interval). @@ -106,7 +106,7 @@ var _ = Describe("Kyma sync into Remote Cluster", Ordered, func() { By("Remote Module Catalog created") Eventually(ModuleTemplateExists, Timeout, Interval). - WithArguments(ctx, skrClient, moduleInSKR, kyma.Spec.Channel). + WithArguments(ctx, skrClient, moduleInSKR, kyma.Spec.Channel, RemoteNamespace). Should(Succeed()) Eventually(containsModuleTemplateCondition, Timeout, Interval). WithArguments(skrClient, skrKyma.GetName(), flags.DefaultRemoteSyncNamespace). @@ -170,13 +170,13 @@ var _ = Describe("Kyma sync into Remote Cluster", Ordered, func() { By("Update SKR Module Template spec.data.spec field") Eventually(UpdateModuleTemplateSpec, Timeout, Interval). WithContext(ctx). - WithArguments(skrClient, moduleInSKR, InitSpecKey, "valueUpdated", kyma.Spec.Channel). + WithArguments(skrClient, moduleInSKR, InitSpecKey, "valueUpdated", kyma.Spec.Channel, RemoteNamespace). Should(Succeed()) By("Expect SKR Module Template spec.data.spec field get reset") Eventually(expectModuleTemplateSpecGetReset, 2*Timeout, Interval). WithArguments(skrClient, - moduleInSKR, kyma.Spec.Channel). + moduleInSKR, kyma.Spec.Channel, RemoteNamespace). Should(Succeed()) }) diff --git a/tests/integration/controller/kyma/kyma_test.go b/tests/integration/controller/kyma/kyma_test.go index dc757e48472..cc2862eae35 100644 --- a/tests/integration/controller/kyma/kyma_test.go +++ b/tests/integration/controller/kyma/kyma_test.go @@ -162,7 +162,8 @@ var _ = Describe("Kyma enable one Module", Ordered, func() { if len(modulesStatus) != 1 { return ErrWrongModulesStatus } - template, err := GetModuleTemplate(ctx, kcpClient, module, v1beta2.DefaultChannel) + template, err := GetModuleTemplate(ctx, kcpClient, module, v1beta2.DefaultChannel, + ControlPlaneNamespace) if err != nil { return err } @@ -515,7 +516,7 @@ func updateKCPModuleTemplateSpecData(kymaName, valueUpdated string) func() error } for _, activeModule := range createdKyma.Spec.Modules { return UpdateModuleTemplateSpec(ctx, kcpClient, - activeModule, InitSpecKey, valueUpdated, createdKyma.Spec.Channel) + activeModule, InitSpecKey, valueUpdated, createdKyma.Spec.Channel, ControlPlaneNamespace) } return nil } diff --git a/tests/integration/controller/kyma/manifest_test.go b/tests/integration/controller/kyma/manifest_test.go index 1f65e33914f..9be2cd79e2c 100644 --- a/tests/integration/controller/kyma/manifest_test.go +++ b/tests/integration/controller/kyma/manifest_test.go @@ -139,7 +139,7 @@ var _ = Describe("Manifest.Spec is rendered correctly", Ordered, func() { RegisterDefaultLifecycleForKyma(kyma) It("validate Manifest", func() { - moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kyma.Spec.Channel) + moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kyma.Spec.Channel, ControlPlaneNamespace) Expect(err).NotTo(HaveOccurred()) expectManifest := expectManifestFor(kyma) @@ -209,7 +209,7 @@ var _ = Describe("Manifest.Spec is reset after manual update", Ordered, func() { }) It("validate Manifest", func() { - moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kyma.Spec.Channel) + moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kyma.Spec.Channel, ControlPlaneNamespace) Expect(err).NotTo(HaveOccurred()) expectManifest := expectManifestFor(kyma) @@ -343,7 +343,8 @@ var _ = Describe("Modules can only be referenced via module name", Ordered, func Context("When operator is referenced just by the label name", func() { It("returns the expected operator", func() { - moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, moduleReferencedWithLabel, kyma.Spec.Channel) + moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, moduleReferencedWithLabel, kyma.Spec.Channel, + ControlPlaneNamespace) Expect(err).ToNot(HaveOccurred()) foundModuleName := moduleTemplate.Labels[shared.ModuleName] @@ -353,14 +354,16 @@ var _ = Describe("Modules can only be referenced via module name", Ordered, func Context("When operator is referenced by Namespace/Name", func() { It("cannot find the operator", func() { - _, err := GetModuleTemplate(ctx, kcpClient, moduleReferencedWithNamespacedName, kyma.Spec.Channel) + _, err := GetModuleTemplate(ctx, kcpClient, moduleReferencedWithNamespacedName, kyma.Spec.Channel, + ControlPlaneNamespace) Expect(err.Error()).Should(ContainSubstring(templatelookup.ErrNoTemplatesInListResult.Error())) }) }) Context("When operator is referenced by FQDN", func() { It("cannot find the operator", func() { - _, err := GetModuleTemplate(ctx, kcpClient, moduleReferencedWithFQDN, kyma.Spec.Channel) + _, err := GetModuleTemplate(ctx, kcpClient, moduleReferencedWithFQDN, kyma.Spec.Channel, + ControlPlaneNamespace) Expect(err.Error()).Should(ContainSubstring(templatelookup.ErrNoTemplatesInListResult.Error())) }) }) @@ -510,7 +513,7 @@ func validateManifestSpecResource(manifestResource, moduleTemplateData *unstruct // getKCPModuleTemplate is a generic ModuleTemplate validation function. func validateKCPModuleTemplate(module v1beta2.Module, kymaChannel string) func(moduleTemplateFn) error { return func(validateFunc moduleTemplateFn) error { - moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kymaChannel) + moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kymaChannel, ControlPlaneNamespace) if err != nil { return err } @@ -527,7 +530,7 @@ func validateKCPModuleTemplate(module v1beta2.Module, kymaChannel string) func(m // updateKCPModuleTemplate is a generic ModuleTemplate update function. func updateKCPModuleTemplate(module v1beta2.Module, kymaChannel string) func(moduleTemplateFn) error { return func(updateFunc moduleTemplateFn) error { - moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kymaChannel) + moduleTemplate, err := GetModuleTemplate(ctx, kcpClient, module, kymaChannel, ControlPlaneNamespace) if err != nil { return err }