Skip to content

Commit

Permalink
separate upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanxin committed Nov 25, 2024
1 parent 801b34a commit fc82f97
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,12 @@ runs:
- name: Apply Template Operator Module and ModuleReleaseMeta for regular and fast channels
working-directory: lifecycle-manager
if: ${{ matrix.e2e-test == 'module-upgrade-channel-switch' ||
matrix.e2e-test == 'module-upgrade-new-version' ||
matrix.e2e-test == 'upgrade-under-deletion' ||
matrix.e2e-test == 'modulereleasemeta-module-upgrade-new-version' ||
matrix.e2e-test == 'modulereleasemeta-upgrade-under-deletion' ||
matrix.e2e-test == 'modulereleasemeta-sync'
}}
shell: bash
run: |
sed -i 's/template-operator-regular/template-operator-2.4.2-e2e-test/g' tests/e2e/moduletemplate/moduletemplate_template_operator_v2_regular_new_version.yaml
sed -i '/^ channel: regular$/d' tests/e2e/moduletemplate/moduletemplate_template_operator_v2_regular_new_version.yaml
./generate_modulereleasemeta.sh template-operator fast:${{ env.NewerVersion }} regular:${{ env.OlderVersion }}
- name: Create Template Operator Module for installation by version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:
- module-without-default-cr
- module-consistency
- non-blocking-deletion
- upgrade-under-deletion
- modulereleasemeta-upgrade-under-deletion
- purge-controller
- purge-metrics
- module-upgrade-channel-switch
- module-upgrade-new-version
- modulereleasemeta-module-upgrade-new-version
- unmanage-module
- skip-manifest-reconciliation
- ca-certificate-rotation
Expand Down
8 changes: 3 additions & 5 deletions pkg/testutils/modulereleasemeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import (

var ErrNotExpectedChannelVersion = errors.New("channel-version pair not found")

func UpdateChannelVersionIfModuleReleaseMetaExists(ctx context.Context, clnt client.Client,
func UpdateChannelVersionInModuleReleaseMeta(ctx context.Context, clnt client.Client,
moduleName, namespace, channel, version string,
) error {
mrm, err := GetModuleReleaseMeta(ctx, moduleName, namespace, clnt)
if err != nil {
if util.IsNotFound(err) {
return nil
}
return fmt.Errorf("get module release meta: %w", err)
}

Expand Down Expand Up @@ -105,7 +102,8 @@ func DeleteModuleReleaseMeta(ctx context.Context, moduleName, namespace string,
return nil
}

func UpdateAllModuleReleaseMetaChannelVersions(ctx context.Context, client client.Client, namespace, name, version string) error {
func UpdateAllModuleReleaseMetaChannelVersions(ctx context.Context, client client.Client,
namespace, name, version string) error {
meta := &v1beta2.ModuleReleaseMeta{}
if err := client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, meta); err != nil {
return err
Expand Down
28 changes: 6 additions & 22 deletions tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,6 @@ e2e-coverage: ginkgo ## Generate the effective Acceptance Criteria for all the t

##@ E2E Tests

test: kyma-deprovision-with-foreground-propagation \
kyma-deprovision-with-background-propagation \
kyma-metrics \
mandatory-module-metrics \
watcher-enqueue \
module-status-decoupling-with-deployment \
module-status-decoupling-with-statefulset \
module-without-default-cr \
module-consistency \
mandatory-module \
non-blocking-deletion \
skip-manifest-reconciliation \
upgrade-under-deletion \
purge-controller \
purge-metrics \
module-upgrade-channel-switch \
module-upgrade-new-version \
module-install-by-version \
ca-certificate-rotation \
self-signed-certificate-rotation \
misconfigured-kyma-secret

kyma-deprovision-with-foreground-propagation:
go test -timeout 20m -ginkgo.v -ginkgo.focus "KCP Kyma CR Deprovision With Foreground Propagation After SKR Cluster Removal"

Expand Down Expand Up @@ -128,6 +106,9 @@ skip-manifest-reconciliation:
upgrade-under-deletion:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Kyma Module Upgrade Under Deletion"

modulereleasemeta-upgrade-under-deletion:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Kyma Module with ModuleReleaseMeta Upgrade Under Deletion"

unmanage-module:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Unmanaging Kyma Module"

Expand All @@ -143,6 +124,9 @@ module-upgrade-channel-switch:
module-upgrade-new-version:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Module Upgrade By New Version"

modulereleasemeta-module-upgrade-new-version:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Module with ModuleReleaseMeta Upgrade By New Version"

module-install-by-version:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Module Install By Version"

Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/module_deletion_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ var _ = Describe("Kyma Module Upgrade Under Deletion", Ordered, func() {
Expect(err).NotTo(HaveOccurred())
GinkgoWriter.Printf(string(out))

By("And ModuleReleaseMeta is updated if it exists")
Eventually(UpdateChannelVersionIfModuleReleaseMetaExists).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, "2.4.2-e2e-test").
Should(Succeed())
})

It("Then Kyma Module is updated on SKR Cluster", func() {
Expand Down
6 changes: 0 additions & 6 deletions tests/e2e/module_upgrade_new_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ var _ = Describe("Module Upgrade By New Version", Ordered, func() {
kcpClient,
newTemplateFilePath)).
Should(Succeed())

By("And ModuleReleaseMeta is updated if it exists")
Eventually(UpdateChannelVersionIfModuleReleaseMetaExists).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, "2.4.2-e2e-test").
Should(Succeed())
})

It("Then Module CR exists", func() {
Expand Down
151 changes: 151 additions & 0 deletions tests/e2e/modulereleasemeta_module_deletion_upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package e2e_test

import (
templatev1alpha1 "github.com/kyma-project/template-operator/api/v1alpha1"

"github.com/kyma-project/lifecycle-manager/api/shared"
"github.com/kyma-project/lifecycle-manager/api/v1beta2"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/kyma-project/lifecycle-manager/pkg/testutils"
)

var _ = Describe("Kyma Module with ModuleReleaseMeta Upgrade Under Deletion", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
module := NewTemplateOperator(v1beta2.DefaultChannel)

InitEmptyKymaBeforeAll(kyma)
CleanupKymaAfterAll(kyma)

Context("Given SKR Cluster", func() {
It("When Kyma Module is enabled on SKR Kyma CR", func() {
Eventually(EnableModule).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, module).
Should(Succeed())
})

It("Then Module Operator is deployed on SKR cluster", func() {
Eventually(CheckIfExists).
WithContext(ctx).
WithArguments(ModuleDeploymentNameInOlderVersion, TestModuleResourceNamespace, "apps", "v1",
"Deployment", skrClient).
Should(Succeed())
By("And KCP Kyma CR is in \"Ready\" State")
Eventually(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateReady).
Should(Succeed())
})

It("When Kyma Module is disabled with existing finalizer", func() {
Eventually(SetFinalizer).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, "operator.kyma-project.io", "v1alpha1",
string(templatev1alpha1.SampleKind),
[]string{"sample.kyma-project.io/finalizer", "blocking-finalizer"}, skrClient).
Should(Succeed())
Eventually(DisableModule).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, module.Name).
Should(Succeed())
})

It("Then KCP Kyma CR is in \"Processing\" State", func() {
Eventually(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateProcessing).
Should(Succeed())

By("And Manifest CR is in \"Deleting\" State")
Eventually(CheckManifestIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), module.Name, kcpClient,
shared.StateDeleting).
Should(Succeed())

By("And Module CR on SKR Cluster is not removed")
Consistently(CheckIfExists).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, "operator.kyma-project.io",
"v1alpha1", string(templatev1alpha1.SampleKind), skrClient).
Should(Equal(ErrDeletionTimestampFound))

By("And Module Operator Deployment is not removed on SKR Cluster")
Consistently(CheckIfExists).
WithContext(ctx).
WithArguments(ModuleDeploymentNameInOlderVersion, TestModuleResourceNamespace,
"apps", "v1", "Deployment", skrClient).
Should(Succeed())
})

It("When ModuleReleaseMeta is updated with new version", func() {
Eventually(UpdateChannelVersionInModuleReleaseMeta).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, "2.4.2-e2e-test").
Should(Succeed())
})

It("Then Kyma Module is updated on SKR Cluster", func() {
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInNewerVersion, TestModuleResourceNamespace).
Should(Succeed())

By("And old Module Operator Deployment is removed")
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion, TestModuleResourceNamespace).
Should(Equal(ErrNotFound))
Consistently(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion, TestModuleResourceNamespace).
Should(Equal(ErrNotFound))

By("And Module CR is in \"Deleting\" State")
Consistently(CheckSampleCRIsInState).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, skrClient, shared.StateDeleting).
Should(Succeed())

By("And Manifest CR is still in \"Deleting\" State")
Consistently(CheckManifestIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), TestModuleName, kcpClient,
shared.StateDeleting).
Should(Succeed())
})

It("When blocking finalizers from Module CR get removed", func() {
Eventually(SetFinalizer).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, "operator.kyma-project.io", "v1alpha1",
string(templatev1alpha1.SampleKind),
[]string{}, skrClient).
Should(Succeed())
})

It("Then Module CR has been deleted in SKR Cluster", func() {
Eventually(CheckIfExists).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, "operator.kyma-project.io", "v1alpha1",
string(templatev1alpha1.SampleKind),
skrClient).
Should(Equal(ErrNotFound))

By("And Module Operator Deployment is deleted")
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInNewerVersion, TestModuleResourceNamespace).
Should(Equal(ErrNotFound))

By("And KCP Kyma CR is in \"Ready\" State")
Eventually(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateReady).
Should(Succeed())
})
})
})
98 changes: 98 additions & 0 deletions tests/e2e/modulereleasemeta_module_upgrade_new_version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package e2e_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kyma-project/lifecycle-manager/api/shared"
"github.com/kyma-project/lifecycle-manager/api/v1beta2"
. "github.com/kyma-project/lifecycle-manager/pkg/testutils"
)

var _ = Describe("Module with ModuleReleaseMeta Upgrade By New Version", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
module := NewTemplateOperator(v1beta2.DefaultChannel)
moduleCR := NewTestModuleCR(RemoteNamespace)

InitEmptyKymaBeforeAll(kyma)
CleanupKymaAfterAll(kyma)

Context("Given SKR Cluster", func() {
It("When Kyma Module is enabled on SKR Kyma CR", func() {
Eventually(EnableModule).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, module).
Should(Succeed())
})

It("Then Module CR exists", func() {
Eventually(ModuleCRExists).
WithContext(ctx).
WithArguments(skrClient, moduleCR).
Should(Succeed())

By("And Module Operator Deployment exists")
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion, TestModuleResourceNamespace).
Should(Succeed())

By("And KCP Kyma CR is in \"Ready\" State")
Eventually(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateReady).
Should(Succeed())
})

It("When version in ModuleReleaseMeta has been upgraded", func() {

Eventually(UpdateChannelVersionInModuleReleaseMeta).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, "2.4.2-e2e-test").
Should(Succeed())
})

It("Then Module CR exists", func() {
Eventually(ModuleCRExists).
WithContext(ctx).
WithArguments(skrClient, moduleCR).
Should(Succeed())

By("And new Module Operator Deployment exists")
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInNewerVersion, TestModuleResourceNamespace).
Should(Succeed())

By("And old Module Operator Deployment does not exist")
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion, TestModuleResourceNamespace).
Should(Equal(ErrNotFound))

By("And KCP Kyma CR is in \"Ready\" State")
Eventually(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateReady).
Should(Succeed())

By("And Kyma Module Version in Kyma Status is updated")
newModuleTemplateVersion, err := ReadModuleVersionFromModuleTemplate(ctx, kcpClient, module,
kyma.Spec.Channel, ControlPlaneNamespace)
Expect(err).ToNot(HaveOccurred())

Eventually(ModuleVersionInKymaStatusIsCorrect).
WithContext(ctx).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), module.Name,
newModuleTemplateVersion).
Should(Succeed())

By("And Manifest Version is updated")
Eventually(ManifestVersionIsCorrect).
WithContext(ctx).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), module.Name,
newModuleTemplateVersion).
Should(Succeed())
})
})
})
2 changes: 1 addition & 1 deletion tests/e2e/modulereleasemeta_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = Describe("ModuleReleaseMeta Sync", Ordered, func() {
It("When Template Operator v2 ModuleTemplate is applied in the KCP Cluster", func() {
v2Version := "2.4.2-e2e-test"
By("And ModuleReleaseMeta is updated with the correct channel-version")
Eventually(UpdateChannelVersionIfModuleReleaseMetaExists).
Eventually(UpdateChannelVersionInModuleReleaseMeta).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, v2Version).
Should(Succeed())
Expand Down

0 comments on commit fc82f97

Please sign in to comment.