From 6c9d7064e083f4a18a36d9d2cfa252817a7080ce Mon Sep 17 00:00:00 2001 From: ChristianZaccaria Date: Mon, 23 Oct 2023 14:51:09 +0100 Subject: [PATCH] Fixing e2e test --- .../genericresource/genericresource.go | 4 ++-- test/e2e/queue.go | 20 +------------------ test/e2e/util.go | 11 +++++----- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/pkg/controller/queuejobresources/genericresource/genericresource.go b/pkg/controller/queuejobresources/genericresource/genericresource.go index 5cdad5fc..c978a169 100644 --- a/pkg/controller/queuejobresources/genericresource/genericresource.go +++ b/pkg/controller/queuejobresources/genericresource/genericresource.go @@ -167,7 +167,7 @@ func (gr *GenericResources) Cleanup(aw *arbv1.AppWrapper, awr *arbv1.AppWrapperG } // Get the resource to see if it exists in the AppWrapper namespace - labelSelector := fmt.Sprintf("%s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace) + labelSelector := fmt.Sprintf("%s=%s, %s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace, resourceName, unstruct.GetName()) inEtcd, err := dclient.Resource(rsrc).Namespace(aw.Namespace).List(context.Background(), metav1.ListOptions{LabelSelector: labelSelector}) if err != nil { return name, gvk, err @@ -310,7 +310,7 @@ func (gr *GenericResources) SyncQueueJob(aw *arbv1.AppWrapper, awr *arbv1.AppWra } // Get the resource to see if it exists - labelSelector := fmt.Sprintf("%s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace) + labelSelector := fmt.Sprintf("%s=%s, %s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace, resourceName, unstruct.GetName()) inEtcd, err := dclient.Resource(rsrc).List(context.Background(), metav1.ListOptions{LabelSelector: labelSelector}) if err != nil { return []*v1.Pod{}, err diff --git a/test/e2e/queue.go b/test/e2e/queue.go index 41341e34..2fd6f1b3 100644 --- a/test/e2e/queue.go +++ b/test/e2e/queue.go @@ -200,7 +200,7 @@ var _ = Describe("AppWrapper E2E Test", func() { appwrappersPtr := &appwrappers defer cleanupTestObjectsPtr(context, appwrappersPtr) - aw := createDeploymentAW(context, "aw-deployment-3", "test") + aw := createDeploymentAW(context, "aw-deployment-3") appwrappers = append(appwrappers, aw) fmt.Fprintf(GinkgoWriter, "[e2e] Awaiting %d pods running for AW %s.\n", aw.Spec.SchedSpec.MinAvailable, aw.Name) @@ -208,24 +208,6 @@ var _ = Describe("AppWrapper E2E Test", func() { Expect(err).NotTo(HaveOccurred()) }) - It("Create Two AppWrappers Same Name Different Namespaces - Deployment Only - 3 Pods Each", func() { - fmt.Fprintf(os.Stdout, "[e2e] Create Two AppWrappers Same Name Different Namespaces - Deployment Only 3 Pods Each - Started.\n") - context := initTestContext() - var appwrappers []*arbv1.AppWrapper - appwrappersPtr := &appwrappers - defer cleanupTestObjectsPtr(context, appwrappersPtr) - - namespaces := []string{"nstest1", "nstest2"} - for _, ns := range namespaces { - aw := createDeploymentAW(context, "aw-deployment-3", ns) - appwrappers = append(appwrappers, aw) - - fmt.Fprintf(GinkgoWriter, "[e2e] Awaiting %d pods running for AW %s in namespace %s.\n", aw.Spec.SchedSpec.MinAvailable, aw.Name, ns) - err := waitAWPodsReady(context, aw) - Expect(err).NotTo(HaveOccurred()) - } - }) - It("Create AppWrapper - Generic Deployment Only - 3 pods", func() { fmt.Fprintf(os.Stdout, "[e2e] Create AppWrapper - Generic Deployment Only - 3 pods - Started.\n") context := initTestContext() diff --git a/test/e2e/util.go b/test/e2e/util.go index aa91fd6e..92050008 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -91,6 +91,7 @@ func initTestContext() *context { Name: cxt.namespace, }, }, metav1.CreateOptions{}) + // Expect(err).NotTo(HaveOccurred()) /* _, err = cxt.kubeclient.SchedulingV1beta1().PriorityClasses().Create(gcontext.Background(), &schedv1.PriorityClass{ @@ -646,8 +647,8 @@ func createJobAWWithInitContainer(context *context, name string, requeuingTimeIn return appwrapper } -func createDeploymentAW(context *context, name string, namespace string) *arbv1.AppWrapper { - rb := []byte(fmt.Sprintf(`{"apiVersion": "apps/v1", +func createDeploymentAW(context *context, name string) *arbv1.AppWrapper { + rb := []byte(`{"apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": "aw-deployment-3", @@ -686,13 +687,13 @@ func createDeploymentAW(context *context, name string, namespace string) *arbv1. ] } } - }} `, namespace)) + }} `) var schedSpecMin int = 3 aw := &arbv1.AppWrapper{ ObjectMeta: metav1.ObjectMeta{ Name: name, - Namespace: namespace, + Namespace: context.namespace, }, Spec: arbv1.AppWrapperSpec{ SchedSpec: arbv1.SchedulingSpecTemplate{ @@ -711,7 +712,7 @@ func createDeploymentAW(context *context, name string, namespace string) *arbv1. }, } - appwrapper, err := context.karclient.WorkloadV1beta1().AppWrappers(namespace).Create(context.ctx, aw, metav1.CreateOptions{}) + appwrapper, err := context.karclient.WorkloadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper