Skip to content

Commit

Permalink
Start E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
nesmabadr committed Jan 14, 2025
1 parent 49e8c2d commit 52ea709
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- modulereleasemeta-watch-trigger
- modulereleasemeta-not-allowed-installation
- labelling

- maintenance-windows-reading
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
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 @@ -64,6 +64,7 @@ jobs:
- rbac-privileges
- ocm-compatible-module-template
- labelling
- maintenance-windows-reading
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
Expand Down
31 changes: 31 additions & 0 deletions pkg/testutils/maintenancewindows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package testutils

import (
"context"

"errors"
"fmt"
"github.com/kyma-project/lifecycle-manager/pkg/util"
v1 "k8s.io/api/core/v1"

Check failure on line 9 in pkg/testutils/maintenancewindows.go

View workflow job for this annotation

GitHub Actions / lint

import "k8s.io/api/core/v1" imported as "v1" but must be "apicorev1" according to config (importas)
"sigs.k8s.io/controller-runtime/pkg/client"
)

var ErrConfigMapNotExist = errors.New("maintenance window configmap does not exist")

func MaintenanceWindowConfigMapExists(ctx context.Context, kcpClient client.Client) error {
cm := &v1.ConfigMap{}

Check failure on line 16 in pkg/testutils/maintenancewindows.go

View workflow job for this annotation

GitHub Actions / lint

variable name 'cm' is too short for the scope of its usage (varnamelen)
objectKey := client.ObjectKey{
Namespace: ControlPlaneNamespace,
Name: "maintenance-config",
}

if err := kcpClient.Get(ctx, objectKey, cm); err != nil {
if util.IsNotFound(err) {
return ErrConfigMapNotExist
}

return fmt.Errorf("could not get configmap: %w", err)
}

return nil
}
3 changes: 3 additions & 0 deletions tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,6 @@ modulereleasemeta-not-allowed-installation:

labelling:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Labelling SKR resources"

maintenance-windows-reading:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Reading Maintenance Window Policy"
42 changes: 42 additions & 0 deletions tests/e2e/maintenance_windows_reading_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package e2e_test

import (
"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"
"os/exec"
)

var _ = Describe("Reading Maintenance Window Policy", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)

InitEmptyKymaBeforeAll(kyma)

Context("Given KCP Cluster With No Maintenance Window File", func() {
It("Then maintenance-config ConfigMap does not exist", func() {
Eventually(MaintenanceWindowConfigMapExists).
WithContext(ctx).
WithArguments(kcpClient).
Should(Equal(ErrConfigMapNotExist))
})

It("When maintenance windows are applied", func() {
cmd := exec.Command("kubectl", "apply", "-k", "../../config/maintenance_windows")
out, err := cmd.CombinedOutput()
Expect(err).NotTo(HaveOccurred())
GinkgoWriter.Printf(string(out))
})

It("Then maintenance-config ConfigMap exists in the KCP Cluster", func() {
Eventually(MaintenanceWindowConfigMapExists).
WithContext(ctx).
WithArguments(kcpClient).
Should(Succeed())

By("And the data read from the ConfigMap is correct")
})
})
})

0 comments on commit 52ea709

Please sign in to comment.