-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
"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{} | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
}) | ||
}) | ||
}) |