|
| 1 | +package parallel |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/onsi/ginkgo/v2" |
| 5 | + . "github.com/onsi/gomega" |
| 6 | + gitopsoperatorv1alpha1 "github.com/redhat-developer/gitops-operator/api/v1alpha1" |
| 7 | + "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" |
| 8 | + deploymentFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/deployment" |
| 9 | + gitopsserviceFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/gitopsservice" |
| 10 | + k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" |
| 11 | + appsv1 "k8s.io/api/apps/v1" |
| 12 | + corev1 "k8s.io/api/core/v1" |
| 13 | + "k8s.io/apimachinery/pkg/api/resource" |
| 14 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 15 | +) |
| 16 | + |
| 17 | +var _ = Describe("GitOps Operator Parallel E2E Tests", func() { |
| 18 | + |
| 19 | + Context("1-120-validate_resource_constraints_gitopsservice_test", func() { |
| 20 | + BeforeEach(func() { |
| 21 | + fixture.EnsureSequentialCleanSlate() |
| 22 | + |
| 23 | + }) |
| 24 | + |
| 25 | + It("validates that GitOpsService can take in custom resource constraints", func() { |
| 26 | + |
| 27 | + By("enabling resource constraints on GitOpsService CR") |
| 28 | + gitopsService := &gitopsoperatorv1alpha1.GitopsService{ |
| 29 | + ObjectMeta: metav1.ObjectMeta{Name: "cluster"}, |
| 30 | + } |
| 31 | + Expect(gitopsService).To(k8sFixture.ExistByName()) |
| 32 | + gitopsserviceFixture.Update(gitopsService, func(gs *gitopsoperatorv1alpha1.GitopsService) { |
| 33 | + gs.Spec.Resources = &corev1.ResourceRequirements{ |
| 34 | + Requests: corev1.ResourceList{ |
| 35 | + "cpu": resource.MustParse("200m"), |
| 36 | + "memory": resource.MustParse("256Mi"), |
| 37 | + }, |
| 38 | + Limits: corev1.ResourceList{ |
| 39 | + "cpu": resource.MustParse("500m"), |
| 40 | + "memory": resource.MustParse("512Mi"), |
| 41 | + }, |
| 42 | + } |
| 43 | + }) |
| 44 | + |
| 45 | + // Ensure the change is reverted when the test exits |
| 46 | + defer func() { |
| 47 | + gitopsserviceFixture.Update(gitopsService, func(gs *gitopsoperatorv1alpha1.GitopsService) { |
| 48 | + gs.Spec.Resources = nil |
| 49 | + }) |
| 50 | + }() |
| 51 | + |
| 52 | + By("verifying the openshift-gitops resources have honoured the resource constraints") |
| 53 | + clusterDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "openshift-gitops"}} |
| 54 | + Eventually(clusterDepl).Should( |
| 55 | + And( |
| 56 | + deploymentFixture.HaveResourceRequirements(&corev1.ResourceRequirements{ |
| 57 | + Requests: corev1.ResourceList{ |
| 58 | + "cpu": resource.MustParse("200m"), |
| 59 | + "memory": resource.MustParse("256Mi"), |
| 60 | + }, |
| 61 | + Limits: corev1.ResourceList{ |
| 62 | + "cpu": resource.MustParse("500m"), |
| 63 | + "memory": resource.MustParse("512Mi"), |
| 64 | + }, |
| 65 | + }), |
| 66 | + ), |
| 67 | + ) |
| 68 | + }) |
| 69 | + }) |
| 70 | +}) |
0 commit comments