Skip to content

Commit

Permalink
Merge branch 'certificates_deletion' of https://github.com/nesmabadr/…
Browse files Browse the repository at this point in the history
…lifecycle-manager into certificates_deletion
  • Loading branch information
nesmabadr committed Jan 7, 2025
2 parents b1fedbe + 7a61c6c commit acc7ee4
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ runs:
matrix.e2e-test == 'misconfigured-kyma-secret' ||
matrix.e2e-test == 'unmanage-module' ||
matrix.e2e-test == 'modulereleasemeta-watch-trigger' ||
matrix.e2e-test == 'modulereleasemeta-with-obsolete-moduletemplate'
matrix.e2e-test == 'modulereleasemeta-with-obsolete-moduletemplate' ||
matrix.e2e-test == 'labelling'
}}
shell: bash
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/deploy-template-operator/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ runs:
matrix.e2e-test == 'module-consistency' ||
matrix.e2e-test == 'skip-manifest-reconciliation' ||
matrix.e2e-test == 'misconfigured-kyma-secret' ||
matrix.e2e-test == 'unmanage-module'
matrix.e2e-test == 'unmanage-module' ||
matrix.e2e-test == 'labelling'
}}
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- module-status-on-skr-connection-lost
- modulereleasemeta-watch-trigger
- modulereleasemeta-not-allowed-installation
- labelling

runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
- misconfigured-kyma-secret
- rbac-privileges
- ocm-compatible-module-template
- labelling
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
Expand Down
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"ocm-compatible-module-template",
"modulereleasemeta-sync",
"modulereleasemeta-not-allowed-installation",
"labelling"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,6 @@ module-status-on-skr-connection-lost:

modulereleasemeta-not-allowed-installation:
go test -timeout 20m -ginkgo.v -ginkgo.focus "ModuleReleaseMeta Not Allowed Installation"

labelling:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Labelling SKR resources"
102 changes: 102 additions & 0 deletions tests/e2e/labelling_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package e2e_test

import (
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
apiappsv1 "k8s.io/api/apps/v1"
apicorev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"

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

. "github.com/kyma-project/lifecycle-manager/pkg/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var managedSkrResources = map[types.NamespacedName]schema.GroupVersionKind{
{Name: "default", Namespace: RemoteNamespace}: v1beta2.GroupVersion.WithKind("Kyma"),
{Name: "skr-webhook", Namespace: RemoteNamespace}: apiappsv1.SchemeGroupVersion.WithKind("Deployment"),
{Name: "skr-webhook", Namespace: RemoteNamespace}: admissionregistrationv1.SchemeGroupVersion.WithKind("ValidatingWebhookConfiguration"),
{Name: "skr-webhook-tls", Namespace: RemoteNamespace}: apicorev1.SchemeGroupVersion.WithKind("Secret"),
{Name: "skr-webhook-sa", Namespace: RemoteNamespace}: apicorev1.SchemeGroupVersion.WithKind("ServiceAccount"),
{Name: RemoteNamespace, Namespace: ""}: apicorev1.SchemeGroupVersion.WithKind("Namespace"),
}

var _ = Describe("Labelling SKR resources", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
InitEmptyKymaBeforeAll(kyma)
CleanupKymaAfterAll(kyma)

module := NewTemplateOperator(v1beta2.DefaultChannel)

Context("Given SKR Cluster", func() {
It("When SKR cluster is setup", func() {
By("Then SKR Kyma CR is labelled with watched-by label")
Eventually(HasExpectedLabel).
WithContext(ctx).
WithArguments(
skrClient,
types.NamespacedName{Name: "default", Namespace: RemoteNamespace},
v1beta2.GroupVersion.WithKind("Kyma"),
shared.WatchedByLabel,
shared.WatchedByLabelValue).
Should(Succeed())
By("And managed SKR resources are labelled with managed-by label")
for name, gvk := range managedSkrResources {
Eventually(HasExpectedLabel).
WithContext(ctx).
WithArguments(
skrClient,
name,
gvk,
shared.ManagedBy,
shared.ManagedByLabelValue).
Should(Succeed())
}
By("And remote namespace is labelled with istio and warden labels")
Eventually(EnsureNamespaceHasCorrectLabels).
WithContext(ctx).
WithArguments(skrClient, RemoteNamespace, map[string]string{
"istio-injection": "enabled",
"namespaces.warden.kyma-project.io/validate": "enabled",
}).Should(Succeed())
})

It("When Kyma Module is enabled in SKR Kyma CR", func() {
Eventually(EnableModule).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, module).
Should(Succeed())
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, ModuleResourceName, TestModuleResourceNamespace).
Should(Succeed())

By("Then all manifest resources are labelled with managed-by label")
manifest, err := GetManifest(ctx, kcpClient, kyma.GetName(), kyma.GetNamespace(),
module.Name)
Expect(err).Should(Succeed())
for _, resource := range manifest.Status.Synced {
name := types.NamespacedName{Name: resource.Name, Namespace: resource.Namespace}
gvk := schema.GroupVersionKind{
Group: resource.Group,
Version: resource.Version,
Kind: resource.Kind,
}
Eventually(HasExpectedLabel).
WithContext(ctx).
WithArguments(skrClient, name, gvk,
shared.ManagedBy, shared.ManagedByLabelValue).Should(Succeed())
}

By("And default CR is labbelled with managed-by label")
Eventually(CheckSampleCRHasExpectedLabel).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, skrClient, shared.ManagedBy,
shared.ManagedByLabelValue).
Should(Succeed())
})
})
})
7 changes: 0 additions & 7 deletions tests/e2e/manifest_reconciliation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ var _ = Describe("Manifest Skip Reconciliation Label", Ordered, func() {
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, skrClient, shared.StateReady).
Should(Succeed())
By("And the SKR Module Default CR has the Managed-by Label")
Eventually(CheckSampleCRHasExpectedLabel).
WithContext(ctx).
WithArguments(TestModuleCRName, RemoteNamespace, skrClient, shared.ManagedBy,
shared.ManagedByLabelValue).
Should(Succeed())

By("And the KCP Kyma CR is in a \"Ready\" State")
Eventually(KymaIsInState).
WithContext(ctx).
Expand Down
7 changes: 0 additions & 7 deletions tests/e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ func InitEmptyKymaBeforeAll(kyma *v1beta2.Kyma) {
WithContext(ctx).
WithArguments(RemoteNamespace, []v1beta2.Module{}, skrClient, shared.StateReady).
Should(Succeed())
By("And Remote Namespace is labelled correctly")
Eventually(EnsureNamespaceHasCorrectLabels).
WithContext(ctx).
WithArguments(skrClient, RemoteNamespace, map[string]string{
"istio-injection": "enabled",
"namespaces.warden.kyma-project.io/validate": "enabled",
}).Should(Succeed())
By("And Runtime Watcher deployment is up and running in SKR", func() {
Eventually(CheckPodLogs).
WithContext(ctx).
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"os/exec"
"time"

apiappsv1 "k8s.io/api/apps/v1"
Expand All @@ -19,7 +20,6 @@ import (
. "github.com/onsi/gomega"

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

const (
Expand Down

0 comments on commit acc7ee4

Please sign in to comment.