Skip to content

Commit

Permalink
Merge branch 'main' into feature/kyma-project#2042-fix-manual-e2e-wor…
Browse files Browse the repository at this point in the history
…kflow
  • Loading branch information
LeelaChacha authored Nov 27, 2024
2 parents 2e7b51d + 4d40611 commit dcedb3b
Show file tree
Hide file tree
Showing 23 changed files with 505 additions and 315 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/get-configuration/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:
echo "k8s_version=${{ github.event.inputs.k8s_version || '1.30.3' }}" >> $GITHUB_OUTPUT
echo "istio_version=1.20.3" >> $GITHUB_OUTPUT
echo "k3d_version=5.7.4" >> $GITHUB_OUTPUT
echo "modulectl_version=1.1.1" >> $GITHUB_OUTPUT
echo "modulectl_version=1.1.3" >> $GITHUB_OUTPUT
echo "cert_manager_version=1.15.0" >> $GITHUB_OUTPUT
echo "klm_version_tag=${{ github.event.inputs.image_tag || format('PR-{0}', github.event.pull_request.number) }}" >> $GITHUB_OUTPUT
echo "klm_image_repo=dev" >> $GITHUB_OUTPUT
Expand Down
34 changes: 34 additions & 0 deletions .github/scripts/release/deploy_modulereleasemeta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -E
set -o pipefail

MODULE_NAME=$1
shift 1
CHANNELS=("$@")
cat <<EOF > module-release-meta.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: ${MODULE_NAME}
namespace: kcp-system
spec:
moduleName: ${MODULE_NAME}
channels:
EOF

for CHANNEL in "${CHANNELS[@]}"; do
IFS=':' read -r CHANNEL_NAME CHANNEL_VERSION <<< "${CHANNEL}"
cat <<EOF >> module-release-meta.yaml
- channel: ${CHANNEL_NAME}
version: ${CHANNEL_VERSION}
EOF
done
kubectl apply -f module-release-meta.yaml

echo "ModuleReleaseMeta created successfully"
rm -f module-release-meta.yaml

kubectl get modulereleasemeta "${MODULE_NAME}" -n kcp-system -o yaml
kubectl get moduletemplate -n kcp-system
41 changes: 41 additions & 0 deletions .github/scripts/release/deploy_moduletemplate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -E
set -o pipefail

MODULE_NAME=$1
RELEASE_VERSION=$2
INCLUDE_DEFAULT_CR=${3:-true}

cat <<EOF > module-config-for-e2e.yaml
name: kyma-project.io/module/${MODULE_NAME}
version: ${RELEASE_VERSION}
security: sec-scanners-config.yaml
manifest: https://localhost:8080/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
EOF

if [ "${INCLUDE_DEFAULT_CR}" == "true" ]; then
cat <<EOF >> module-config-for-e2e.yaml
defaultCR: https://localhost:8080/config/samples/default-sample-cr.yaml
EOF
fi

cat module-config-for-e2e.yaml
modulectl create --config-file ./module-config-for-e2e.yaml --registry http://localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
kubectl apply -f template.yaml

cat template.yaml
echo "ModuleTemplate created successfully"

rm -f module-config-for-e2e.yaml
rm -f template-operator.yaml
rm -f template.yaml
rm -f default-sample-cr.yaml
echo "Temporary files removed successfully"
19 changes: 15 additions & 4 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,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 All @@ -58,7 +58,6 @@ jobs:
- mandatory-module-metrics
- misconfigured-kyma-secret
- rbac-privileges
- ocm-compatible-module-template
- modulereleasemeta-with-obsolete-moduletemplate
- modulereleasemeta-sync
- modulereleasemeta-watch-trigger
Expand Down Expand Up @@ -105,7 +104,19 @@ jobs:

- name: Deploy template-operator
uses: ./lifecycle-manager/.github/actions/deploy-template-operator-with-modulereleasemeta

env:
ModuleDeploymentName: template-operator-controller-manager
ModuleDeploymentNameInNewerVersion: template-operator-v2-controller-manager
ModuleDeploymentNameInOlderVersion: template-operator-v1-controller-manager
NewerVersion: 2.4.2-e2e-test
OlderVersion: 1.1.1-e2e-test
VersionForStatefulSetInWarning: 1.0.0-warning-statefulset
VersionForDeploymentInWarning: 1.0.0-warning-deployment
VersionForMisconfiguredDeploymentImage: 1.0.0-misconfigured-deployment
VersionForMisconfiguredStatefulSetImage: 1.0.0-misconfigured-statefulset
VersionForNoDefaultCR: 1.0.0-no-default-cr
MisconfiguredModuleName: template-operator-misconfigured
ModuleName: template-operator
- name: Run '${{ matrix.e2e-test }}' test
working-directory: lifecycle-manager
run: |
Expand Down
11 changes: 8 additions & 3 deletions internal/declarative/v2/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ import (
"github.com/kyma-project/lifecycle-manager/pkg/util"
)

var ErrResourceSyncDiffInSameOCILayer = errors.New("resource syncTarget diff detected but in " +
"same oci layer, prevent sync resource to be deleted")
var (
ErrManagerInErrorState = errors.New("manager is in error state")
ErrResourceSyncDiffInSameOCILayer = errors.New("resource syncTarget diff detected but in " +
"same oci layer, prevent sync resource to be deleted")
)

const (
namespaceNotBeRemoved = "kyma-system"
Expand Down Expand Up @@ -376,7 +379,9 @@ func (r *Reconciler) checkManagerState(ctx context.Context, clnt Client, target
if err != nil {
return shared.StateError, err
}

if managerState == shared.StateError {
return shared.StateError, ErrManagerInErrorState
}
return managerState, nil
}

Expand Down
9 changes: 4 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,9 @@ 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
2 changes: 1 addition & 1 deletion tests/e2e/mandatory_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var _ = Describe("Mandatory Module Installation and Deletion", Ordered, func() {
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, v1beta2.Module{
Name: TestModuleName,
Channel: "regular",
Channel: v1beta2.DefaultChannel,
Managed: true,
}).
Should(Succeed())
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/mandatory_modules_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ var _ = Describe("Mandatory Module Metrics", Ordered, func() {
CleanupKymaAfterAll(kyma)

Context("Given SKR Cluster", func() {
const deployName = "template-operator-v1-controller-manager"
It("Then mandatory module is installed on the SKR cluster", func() {
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, deployName,
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion,
TestModuleResourceNamespace).
Should(Succeed())
By("And the SKR Module Default CR is in a \"Ready\" State", func() {
Expand Down Expand Up @@ -68,7 +67,7 @@ var _ = Describe("Mandatory Module Metrics", Ordered, func() {
It("Then mandatory SKR module is removed", func() {
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, deployName,
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion,
TestModuleResourceNamespace).
Should(Equal(ErrNotFound))

Expand Down
6 changes: 0 additions & 6 deletions tests/e2e/module_deletion_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ var _ = Describe("Kyma Module Upgrade Under Deletion", Ordered, func() {
out, err := cmd.CombinedOutput()
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
5 changes: 3 additions & 2 deletions tests/e2e/module_install_by_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var _ = Describe("Module Install By Version", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
templateOperatorModule := NewTemplateOperatorWithVersion("2.4.2-e2e-test")
templateOperatorModule := NewTemplateOperatorWithVersion(NewerVersion)
moduleCR := builder.NewModuleCRBuilder().
WithName("sample-2.4.2-e2e-test").
WithNamespace(RemoteNamespace).Build()
Expand Down Expand Up @@ -50,7 +50,8 @@ var _ = Describe("Module Install By Version", Ordered, func() {
By("And Module is in \"Ready\" State")
Eventually(CheckModuleState).
WithContext(ctx).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), templateOperatorModule.Name, shared.StateReady).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), templateOperatorModule.Name,
shared.StateReady).
Should(Succeed())
})
})
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/module_status_decoupling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
func RunModuleStatusDecouplingTest(resourceKind ResourceKind) {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
module := NewTemplateOperator(v1beta2.DefaultChannel)
moduleWrongConfig := NewTestModuleWithFixName("template-operator-misconfigured", "regular", "")
moduleWrongConfig := NewTestModuleWithFixName(MisconfiguredModuleName, v1beta2.DefaultChannel, "")
moduleCR := NewTestModuleCR(RemoteNamespace)
InitEmptyKymaBeforeAll(kyma)
CleanupKymaAfterAll(kyma)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/module_upgrade_channel_switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("Module Upgrade By Channel Switch", Ordered, func() {
It("When downgrade version by switch Channel", func() {
Eventually(UpdateKymaModuleChannel).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, "regular").
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, v1beta2.DefaultChannel).
Should(Succeed())
})

Expand Down
8 changes: 1 addition & 7 deletions tests/e2e/module_upgrade_new_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,8 @@ 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())
})

//nolint:dupl //this test will be deleted during this issue https://github.com/kyma-project/lifecycle-manager/issues/2060
It("Then Module CR exists", func() {
Eventually(ModuleCRExists).
WithContext(ctx).
Expand Down
Loading

0 comments on commit dcedb3b

Please sign in to comment.